PHP date function not accepting timezone change
        Posted  
        
            by Pepper
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pepper
        
        
        
        Published on 2010-05-22T19:21:00Z
        Indexed on 
            2010/05/22
            19:30 UTC
        
        
        Read the original article
        Hit count: 356
        
Hello,
I've set up a quick little test to understand and debug timezones between mySQL and PHP.
Here's the page: http://dev.feedingo.com/test_dates.php
The dates are being created in mySQL using NOW() in a datetime field. The initial problem I was trying to figure out is what timezone mySQL is using and how to sync it up with PHP. But now there's an even weirder issue.
In my test app, if you change your timezone, the first strtotime updates properly, but if you pass it into a date() function it doesn't change. This is how im setting the timezone based off the select box.
    $current_timezone = 'America/New_York';
if( isset( $_GET['timezone'] ) ) $current_timezone = $_GET['timezone'];
date_default_timezone_set($current_timezone);
Any ideas as to why the date() function isn't accepting the timezone changes? Thanks!
© Stack Overflow or respective owner