We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Imported data & localization settings

Development and Programming

matrixgroup's avatar
matrixgroup
15 posts
14 years ago
matrixgroup's avatar matrixgroup

I’ve run into this issue on a few sites which I have built and am trying to understand exactly what is going on behind the scenes.

We are pulling data from an external system in two different methods and both methods show incorrect dates. The first way is through a plugin which makes a webservice call the the system, and the second method involved importing the entries directly into the EE database. The system we are pulling information from stores published date for all of its entries at midnight on the day it was published.

09/21/2011 00:00:00 09/20/2011 00:00:00 etc.

When I use the format parameter to display the dates through a template tag they come out one hour earlier.(09/20/2011 23:00:00, 09/19/2011 23:00:00, etc). If I use the php date() function the dates display correctly.

The first time this issue came up I noticed that Daylight Saving Time in the localization settings was set to no, and changing this to yes fixed the issue. So I have made sure to set this on all subsequent sites.

I am beginning to wonder if there is something I am doing incorrectly when I’ve been importing this data. For the data import I am using

$data['entry_date']             = strtotime($row->publicationDate);
$this->EE->api_channel_entries->submit_new_entry($channel_id, $data);

$row is a database object from other CMS’ database. The plugin also does something similar

$meeting->meeting_start_date = strtotime($meeting->meeting_start_date);
$meeting->meeting_end_date = strtotime($meeting->meeting_end_date);
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata,$meeting);

With the end of daylight savings time approaching, I am concerned about what will happen if the daylight savings time switch is switched to no. If DST is turned off on November 6th will the the dates be an hour off again? How will it affect entries that were entered when dst was turned on will all of them be a hour newer?

I also have several sites each with a good number of users. Is there anything which automatically adjusts for daylight savings time or am I going to have to go through and adjust these settings manually? What if any side effects could we experience if we leave daylight savings time turned on all year round.

       
Wes Baker's avatar
Wes Baker
343 posts
14 years ago
Wes Baker's avatar Wes Baker

matrixgroup,

I moved this to Development and Programming since it makes more sense over there.

Taking a look at what you have, it looks like everything is correct. I’d first start checking to see if your original $data[‘entry_date’] matches what’s going into the database, it should, but it’s good to check.

I think the actual problem is that ExpressionEngine assumes all dates in the database are in the GMT timezone. To correct the date to that time zone, try something like this:

$data['entry_date'] = strtotime($row->publicationDate) + (60 * 60 * 5);

That would add 5 hours (hence the 60 (seconds) * 60 (minutes) * 5 (hours)) to your time bringing it to GMT if you were normally on the east coast.

See if that fixes your problem.

Wes

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.