Closed (fixed)
Project:
Date
Version:
6.x-2.x-dev
Component:
Date Timezone
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Feb 2009 at 19:30 UTC
Updated:
13 Mar 2009 at 00:50 UTC
We created several hundred nodes, a custom content type 'event' for an event calendar, before we set a time zone for our site.
Since we did not have a time zone set, all our log messages were off by 6 hours. So, I set the proper time zone.
As you might imagine, all the events were suddenly off by a large differential, I think 7 hours.
So, does anyone have suggestion on how I might fix my data. Do I need to work out a sql statement that will add the proper amount of hours to each date field to match the desired time zone?
Comments
Comment #1
karens commentedThe exact way to fix this will depend on what kind of date you are using, and whether or not you have dates that use different offsets (like when some are before and others after a change in daylight savings time), and what kind of timezone handling you are using.
Almost anything I can think of would be fairly complicated to do in SQL. I think it would be easier to write a small custom PHP script like the following. You'll have to play around with it to see exactly what gives you the right results:
Where
- TABLE is the table where your date data is stored,
- FIELD_NAME is the name of your field,
- DATETYPE is the type of date, 'date', 'datestamp' or 'datetime',
- DB_TIMEZONE is the timezone the data got stored as originally (UTC if you're using the site timezone, that bad timezone if you're using no timezone handling)
Comment #2
karens commentedAnd then empty the cache_content table after you finish doing this or you'll keep seeing the old, cached values of the nodes.
Comment #3
justageek commentedThanks much. We are not doing anything special with daylight savings time, and the users are just using the nice calendar widget to select a date and time in two date fields. So, I just need to figure out how much time is added when I turn on the correct time zone, then use your php script to adjust the other direction.
Thanks again!
Comment #4
karens commentedI see I missed a step above. I created a date but didn't update the node value. You'll need to update $node->FIELD_NAME[0]['value'] and $node->FIELD_NAME[0]['value2'] with the new date before saving the node.