• Resolved sterfry68

    (@sterfry68)


    Found this on line 36 in wp-settings.php:

    date_default_timezone_set( ‘UTC’ );

    For me it’s changing the default timezone and never getting changed back to the one in my options table.

    I’m creating events on my site that need to be in the right timezone. But my system timezone was always in UTC until I commented out the line above. As a temporary solution I am explicitly changing the timezone back to my local when I need it.

    Is this a problem others have noticed or am I just doing something wrong?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Your timezone is a setting in the dashboard – settings – general.

    I’d stay out of wp-settings.php.

    Thread Starter sterfry68

    (@sterfry68)

    Hi Peter,

    Thanks for the response. However that’s not my issue. I’m wondering if this is a bug in the core. That particular line in the wp-settings.php file seems to be changing the timezone to UTC independent of what you set it to in the dashboard, and it never changes it back. Anyone else seeing this?

    Thread Starter sterfry68

    (@sterfry68)

    FYI. As a temporary solution I’ve created this function. I call it every time I need to use my local time (America/Denver).

    function zzz_reset_timezone(){
    /*the core seems to be changing the timezone to UTC: (wp-settings.php line
    * 36) and never changig it back; change it to what it’s set to in the
    * options table as a temporary fix.
    */
    $current_offset = get_option(‘gmt_offset’);
    $tzstring = get_option(‘timezone_string’);

    if ( false !== strpos($tzstring,’Etc/GMT’) )
    $tzstring = ”;

    if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
    if ( 0 == $current_offset )
    $tzstring = ‘UTC+0’;
    elseif ($current_offset < 0)
    $tzstring = ‘UTC’ . $current_offset;
    else
    $tzstring = ‘UTC+’ . $current_offset;
    }

    date_default_timezone_set( $tzstring );
    //end code for temporary fix
    }

    I have no idea what you’re on about 🙂

    As a test, I changed my wp dashboard timezone to UTC+5.
    Then I pulled the wp-settings.php page. It said:

    // WordPress calculates offsets from UTC.
    date_default_timezone_set( 'UTC' );

    Might help you?

    Thread Starter sterfry68

    (@sterfry68)

    If you run this: <?php echo date_default_timezone_get(); ?> what do you see? Do you see the timezone that you set in dashboard? Or do you see UTC? No matter what I set in the dashboard, the above code returns UTC for me. The cuprit for me is the line that you identified in your latest post.

    I’m not trying to resolve an issue. I’m trying to identify what might be a bug in the wp-settings file.

    Maybe this isn’t the place to report potential bugs?

    Above code returned UTC for me too.

    Are you sure WP settings override PHP settings?

    This probably isn’t the right place for it.

    And I’m pulling out of this thread, good luck 🙂

    Thread Starter sterfry68

    (@sterfry68)

    Yes, I’m sure. That’s what date_default_timezone_set() does. It changes your application’s timezone from the default set on your server. I checked and both my php.ini file and .htaccess file are set to the right timezone.

    This must be a bug if it’s returning UTC for you too.

    Anyone know where post bugs?

    Thread Starter sterfry68

    (@sterfry68)

    found it

    http://codex.wordpress.org/Reporting_Bugs

    I’m going to report this as a bug

    Thread Starter sterfry68

    (@sterfry68)

    FYI for those who might also run into this problem:

    Looks like this is NOT a bug but expected behavior. PHP’s date() function will always return UTC. Should use wordpresses current_time() function instead. Did not know!

    You can read more here:

    http://core.trac.wordpress.org/ticket/23384

    Thread Starter sterfry68

    (@sterfry68)

    resolved

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Timezone Overwritten in Core?’ is closed to new replies.