ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

ExpressionEngine time zone issues

December 11, 2013 12:36pm

Subscribe [2]
  • #1 / Dec 11, 2013 12:36pm

    moki

    26 posts

    I’m having timezone issues with EE 2.7.2—here’s a simple test PHP script I’m using to output the date:

    <?php
    print date(‘r’);
    print “, “;
    print date(‘D, d M Y H:i:s T’);
    print “\n”;
    ?>

    When run inside of a template with php parsing enabled in EE, this outputs:

    Wed, 11 Dec 2013 17:31:13 +0000, Wed, 11 Dec 2013 17:31:13 UTC

    When run as a stand-alone PHP script in the same server, I get this as a result:

    Wed, 11 Dec 2013 09:29:21 -0800, Wed, 11 Dec 2013 09:29:21 PST

    The latter is correct; it’s displaying in the timezone of the server:

    [admin@crushlivepoker scripts]$ date
    Wed Dec 11 09:31:58 PST 2013

    I confirmed that PHP has the proper timezone configured in php.ini:

    [admin@crushlivepoker scripts]$ php -i | grep timezone
    Default timezone => US/Pacific
    date.timezone => US/Pacific => US/Pacific

    So I’d assume this is an EE issue of some sort; I checked Admin->Localization Settings and the timezone is indeed set correctly there.

    What am I missing?

  • #2 / Dec 12, 2013 11:32am

    moki

    26 posts

    I was told this:

    Since EE2.6, time is not interpreted through native EE function, but rather
    through a simple date(...) function, which does not work.

    Anyone aware of this?  Should I just explicitly set the timezone in my PHP code?  Why is there even a timezone setting in EE if this is the case?

  • #3 / Dec 16, 2013 3:36am

    Bjørn Børresen

    629 posts

    Have you tried to get the timestamp from $this->EE->localize->now?

    In addition to the default timezone set up in EE there’s also one for users, where they may have a certain timezone set (Found under Edit profile -> Localization). This might be your issue (if you are logged in as a user with a different timezone set than your server timezone).

    Also, there’s a config item called “server_offset” which specifies the minutes to offset the server time with. This will affect the value returned from $this->EE->localize->now

    by the way, this place is a ghosttown compared to http://expressionengine.stackexchange.com/ .. you’ll probably have more luck asking EE related questions there.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases