• I’m using the PHP date character “T” to show the time zone in my posts. The trouble is that “T” seems to be showing the server’s time zone and not the time zone I set in WordPress.

    The server is on the west coast, but WordPress is set to the east coast time zone. I want my time stamps to show “EST” not “PST”. I can set the time zones manually (just write “EST” after the PHP time stamp code), but it looks like I can’t get to this info easily for the comments without going outside of my theme templates.

    Does anyone know of another way to show the time zone set in WordPress instead of the server’s time zone?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi,

    You can change the time zone details from wordpress admin area -> settings -> general option.

    Thanks,

    Shane G.

    Thread Starter evi1pilotfish

    (@evi1pilotfish)

    Yes, I’ve already done that – as I said, I’ve set the time zone in WordPress to be EST, but the PHP date character “T” is returning the server’s time zone and not the time zone I’m setting in the admin area.

    Thread Starter evi1pilotfish

    (@evi1pilotfish)

    No one else has tried to display their time zone using the PHP date character “T”?

    I have the very same problem.

    WP2.8.4 with PHP 5.2.6

    It appears the tag the_time() returns the date/time in the LOCAL SERVER timezone and NOT that specified in the admin/settings/general page.
    That is to say that I posted a new test post at 20:52 UTC with the blog set to use UTC timezone (in admin), changed the template to show the timezone the_time(‘jS M Y H:i e’) and the date/time showed as “20:52 America/Los_Angeles”.

    I’ve tried an auto and a manual setting. Changing the default timezone using php date_default_timezone_set().

    There is clearly a bug in WP that is not setting the PHP default timezone to match the timezone set in the admin interface.

    This will only affect blogs that are not in the same timezone as the server the blog is running from.

    Regards,
    Julian Knight

    Found the issue.

    Running on a server that is not setting the TZ in a way that PHP when run as FastCGI can pick up!

    Set the TZ in .htaccess to be the same as the Blog TZ:
    SetEnv TZ Europe/London

    Anything else returns incorrect values from the_time()

    See:
    http://wordpress.org/support/topic/307024?replies=4#post-1197247

    Oops, actually just setting the TZ in .htaccess seems to fix the issue altogether. It doesn’t seem to matter that much what you set it to!

    No, forget that. I added some debugging code to index.php

    It turns out that if I use the_time() on its own, I always get the TZ of my server (in LA).

    If, however, I add the code:
    $gmtOffset=get_option('gmt_offset');

    I get the correct TZ – that of the Blog TZ set in admin.

    I can’t think that this is correct, reported as a bug.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WordPress Time Zone Instead of Server Time Zone’ is closed to new replies.