• Resolved Emily

    (@cleanup)


    Greetings! I have one hair left due to this issue. No matter what I do, I can’t get the UTC time to set correctly.

    We have our hosting with MediaTemple on a DV server. We are using WordPress multisite, though it does the same thing with a regular WordPress installation, clean with no plugins or themes installed.

    We’re in the eastern US time zone, but the time shown in WordPress settings never changes even when I set the timezone in Plesk and restart Apache. No matter what changes I make to the timezone in Plesk, WordPress does not change, it keeps reporting the same thing. I’ve also tried setting UTC time zone in php.ini and it has no effect at all. The time is reported correctly in UTC when I use the “uptime” command on the server.

    Right now, it’s 2:56pm here in Florida. I have WordPress set to UTC time zone. And it reports this on the settings page:
    Universal time (UTC) is 2017-01-06 14:56:02

    UTC should be 19:56.

    I have asked MediaTemple support multiple times for help and they have not been able to assist. It’s messing up the cron schedule in WordPress and making it so we can’t schedule posts. Yes, I know I can get a plugin to fix that but I want to fix the underlying problem.

    What else can I check or do to correct this?

    Thank you!

Viewing 15 replies - 1 through 15 (of 35 total)
  • Moderator t-p

    (@t-p)

    Hi Emily,

    Here are a few things to check:
    -Sounds like UTC is set wrong on the apache level.
    – or,a plugin may be forcing that to be something weird.
    – to rule out ant plugin issue, try deactivating ALL (yes all) plugins temporarily to see if this resolves the problem. If this works, re-activate them individually (one-by-one) to find the problematic plugin(s).

    Thread Starter Emily

    (@cleanup)

    Thanks, t-p. I’ve ruled out plugin and theme issues by installing a clean copy of WordPress, completely unrelated to the main site. And it does exactly the same thing.

    I don’t know what else to check in Apache and am hoping someone can give me some guidance!

    Moderator t-p

    (@t-p)

    Is this your own server (i.e., local server) or a remote server (hosting provider)?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Log into your server via SSH. Type the “date” command. You should get back a correct UTC time, like so:

    
    $ date
    Fri Jan  6 22:07:31 UTC 2017
    

    Does that work properly? If not, then the server time is set incorrectly.

    Thread Starter Emily

    (@cleanup)

    The date command returns the correct UTC time: Fri Jan 6 22:13:40 GMT 2017

    We’re hosted at MediaTemple with a DV server.

    Thread Starter Emily

    (@cleanup)

    phpinfo shows this:

    date/time support enabled
    “Olson” Timezone Database Version 0.system
    Timezone Database internal
    Default timezone UTC

    Directive Local Value Master Value
    date.default_latitude 31.7667 31.7667
    date.default_longitude 35.2333 35.2333
    date.sunrise_zenith 90.583333 90.583333
    date.sunset_zenith 90.583333 90.583333
    date.timezone UTC UTC

    Could it have something to do with the latitude and longitude?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Okay, the time can’t be adjusted correctly without a setting somewhere.

    PHP gets the time from the server. It assumes the server reports UTC time.

    WordPress tells PHP to use UTC time everywhere. WordPress then makes its own correction for local time based on your setting in the general page.

    So, if you have set everything to UTC, and still get Eastern Time, then you missed something, somewhere, because some correction is being applied. Somehow.

    Disclaimer: I wrote a lot of this timezone handling code several years ago. It’s been a while since I looked at it again, but essentially what you’re describing is not possible without something else you’re not describing. Dunno what.

    I looked at my blog. If I SSH into the server and do a date command, I get:

    Sat Jan 7 00:24:41 EST 2017

    The server is in Florida, so set to Eastern time zone. In my PHP.INI I set date.timezone = “America/Chicago” so everything is in my local time here in Oklahoma. (This affects all my domains the way I have it set.).

    Anyway, In WordPress I have Chicago selected as the timezone and below, it has:

    Universal time (UTC) is 2017-01-06 23:23:55. Local time is 2017-01-06 17:23:55.

    In fact, Local time is 2017-01-06 23:23:55 (or 11:23pm central) and UTC is really 5:23am on Jan 7th.

    Now, everything in my blog is working fine as it is recording everything in the correct Central time. So, I’m wondering if it shows the wrong UTC time for me, that it’s assuming the wrong time for her?

    Note: If I change the PHP.INI to not set the timezone or make it UTC, WordPress still shows the wrong UTC time in this spot.

    • This reply was modified 7 years, 9 months ago by MarkRH.

    Same problem for me, MediaTemple has no idea.
    My DV is set to UTC, WordPress is set to Manila.
    PHP is set to UTC. Using a override like date.timezone=UTC or via pHP function makes no difference either.

    All times are 5 hours off – Both UTC and Local time.
    The GMT+0 vs London and GMT+8 vs Manila setting makes no difference.
    They’re all 5 hours off.

    Thread Starter Emily

    (@cleanup)

    The server seems to be fine with the date:

    [root]# timedatectl
          Local time: Sun 2017-01-08 11:39:06 EST
      Universal time: Sun 2017-01-08 16:39:06 UTC
            RTC time: n/a
           Time zone: America/New_York (EST, -0500)
         NTP enabled: no
    NTP synchronized: yes
     RTC in local TZ: no
          DST active: no
     Last DST change: DST ended at
                      Sun 2016-11-06 01:59:59 EDT
                      Sun 2016-11-06 01:00:00 EST
     Next DST change: DST begins (the clock jumps one hour forward) at
                      Sun 2017-03-12 01:59:59 EST
                      Sun 2017-03-12 03:00:00 EDT
    

    Could it be the lack of RTC (real-time clock)? What can I check in PHP settings?

    Here’s some info I found about the above output:
    -RTC time is the hardware clock. Compare it to the Local time and Universal times returned by timedatectl to determine how the hardware clock is set.
    -RTC in local TZ: no means the hardware clock is interpreted as UTC
    -RTC in local TZ: yes means the hardware clock is interpreted as local time

    • This reply was modified 7 years, 9 months ago by Emily. Reason: Additional info about clock output
    Thread Starter Emily

    (@cleanup)

    I think I’ve got another clue… when I use this plain PHP script

    <?php echo date(“Y-m-d G:i:s”, $_SERVER[‘REQUEST_TIME’]); ?>

    it returns the current date and time here in Florida. It’s my understanding that this server variable is supposed to be a Unix timestamp, so shouldn’t the output be in GMT?

    Try gmdate();
    But even then, for me, UTC is 5 hours off, same as your initial example.

    Mediatemple is not much help, they blame WP… ??

    Thread Starter Emily

    (@cleanup)

    gmdate() says the correct time!

    • This reply was modified 7 years, 9 months ago by Emily. Reason: Testing revealed a different result

    There’s a bug somewhere in that options page related to the date_i18n() function and displaying the UTC time I think. The PHP time() function always returns a UTC timestamp which the current_time() function does use.

    It’s like it’s applying the timezone offset once for UTC and twice for the Local time. I’d have to add some debug lines in the various functions and record values for various things to see what’s going on where.

    If that’s the case then why is it (so far) specific for certain types of hosting (MediaTemple DV in this case).

    I have another site using the same WP on their Grid hosting and it’s fine there.
    Also I have a bunch of testing sites on a localhost and it works there too.

    Perhaps this helps where PHP is concerned – https://ajdg.solutions/date.php
    Some examples that work and don’t work – The only one that’s correct is the Manila timezone.

Viewing 15 replies - 1 through 15 (of 35 total)
  • The topic ‘UTC time wrong’ is closed to new replies.