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.

EE Current Time does not match Server Time

July 16, 2012 10:22am

Subscribe [2]
  • #1 / Jul 16, 2012 10:22am

    soire

    25 posts

    Hello!

    Perhaps this is an easy answer that I’m just misunderstanding, but here goes anyways.

    I’ve got a site that features an “event” system whereby I’m listing events by limiting my channel entries as follows:

    {exp:channel:entries 
     channel="events" 
     disable="categories|category_fields|member_data|pagination"
     limit=""
     orderby="date"
     sort="asc"
     start_on="{current_time format='%Y-%m-%d %H:%i'}"
     show_future_entries="yes"
     }
     ---stuff---
    {/exp:channel:entries}

    The idea is that for each entry, we use the entry date as the date of the event and then to make sure that it appears on the site for the entire day, we manually type in 11:59 PM. This kinda works, except that I noticed by chance recently that events were being dropped sooner than 11:59 PM.

    After some investigation, I discovered that our server time (MediaTemple Grid Service) was actually about 9 hours ahead of where we were. To combat this, I’ve used both a php.ini file and .htaccess to set the server time to our closest actual region (America/Chicago). I’ve tested this by a PHP script that shows the correct date/time.

    <?php
    print strftime('%c');
    ?>

    However, when I attempt to check that EE is matching this, I am getting that same, old time that is 9 hours ahead:

    {current_time format="%Y %m %d %H:%i:%s"}

    I first thought it might be browser cache playing into this, but alas I’ve checked multiple machines and browsers and it is still off. My EE localization settings are as follows:

    Server Time Zone: (UTC -6:00) Central Standard Time
    Server Offset (in minutes): 0
    Default Time formatting: United States
    Daylight Saving Time: Yes

    Is there anything I can do to refresh or reset EE to match the server time?

    EE v2.5.1 - Build Date: 20120529

  • #2 / Jul 17, 2012 4:09pm

    Shane Eckert

    7174 posts

    Hey,

    Time can sometimes be an issue.

    ExpressionEngine wants both the server time and PHP to match up.

    ExpressionEngine uses native PHP functions to deal with dates and times, which base their output on the timezone of the server.

    What happens if you play with the server offset? Not saying that is the solution, but interested in what that does for you.

    Please let me know.

    Cheers,

     

  • #3 / Jul 17, 2012 4:28pm

    soire

    25 posts

    Thanks for your reply Shane. I’ve tried the server offset, but that means that I have LOTS of entries that get their entry time set to an undesirable value as changing the offset also changes the entry date/time.

    In either case, there is some kind of discrepancy between EE and the way PHP is displaying time. Is there a way I can reset EE?

  • #4 / Jul 18, 2012 1:22pm

    Shane Eckert

    7174 posts

    Hey soire,

    Understood. We will leave the offset alone.

    I will try and explain how the time settings work with ExpressionEngine.

    The server’s settings are defined in Admin->Localization Settings
.

    Here you want to make sure the Time Zone is set correctly and reflects the timezone the server is located in. Don’t worry about the Server Offset, that is rarely used and is intended to make minor adjustments. It’s also important to keep your server’s DST settings accurate through the year.

    ExpressionEngine stores dates and times in a UNIX timestamp format that relates to GMT. Then the timestamp is offset by the value of your timezone setting for the server.

    The other side of this is the localization for your own Member account. Click the “My Account” link on the far right of the Control Panel and then check your Localization Settings. Make sure your timezone and DST settings are accurate as well.

    To bring it all together, ExpressionEngine will display dates and times localized based on your settings, if you are logged into the front of your site. If no one is logged in, dates and times are localized to the server’s settings.

    The option between localized and fixed will determine how you want it to be displayed. Localized will be dependent on the user’s logged in state, fixed will always use the server’s localization settings.

    With all these things considered, does {current_time format="%Y %m %d %H:%i:%s"} still return the wrong time?

    If so, I may need to take a look, just to see for myself and get my head around this.

    Thank you,

  • #5 / Jul 18, 2012 4:19pm

    soire

    25 posts

    Hi Shane

    We have three EE members (super admin, plus two editors) that all have their localization settings to the same setting, which subsequently is the same time setting as the server setup should. I will PM you with CP access so you can look around. Thanks for your help!

  • #6 / Jul 18, 2012 4:28pm

    soire

    25 posts

    Hmm. Your inbox is full according to the PM attempt. Do you have an email address I can contact you directly at?

  • #7 / Jul 19, 2012 12:24pm

    Shane Eckert

    7174 posts

    Hello soire,

    We do not use the PM system in general, it keeps support to the official channels and it prevents users from sending credentials to an insecure location.

    Please be on the look out for an email from EllisLab.

    Cheers,

  • #8 / Aug 20, 2012 1:27pm

    Kevin Smith

    4784 posts

    Hi soire,

    Just wanted to follow-up with you to see if you got our email. If you need us to re-send it, just let us know!

  • #9 / Aug 20, 2012 3:07pm

    soire

    25 posts

    Hi Guys

    I got your emails-thank you for your help. Due to the urgency of the situation, I had to go another route, so for the time being, I no longer need help on this issue.

    Thank you anyhow!

  • #10 / Aug 21, 2012 11:22am

    Shane Eckert

    7174 posts

    Hey soire,

    Understood. Glad that you are back in business.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases