Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Bug #14042 Timezone conversion wrong
Submitted: 2008-06-02 02:25 UTC
From: jmarcv Assigned:
Status: Open Package: Date (version 1.5.0a1)
PHP Version: 5.0.2 OS: red hat Linux
Roadmaps: (Not assigned)    
Subscription  


 [2008-06-02 02:25 UTC] jmarcv (John Ventimiglia)
Description: ------------ I don't know where else to put this - I get same result on 1.4 and this seems to be too obvious for it to still be around, but I just can't see what it is I am doing wrong. Test script: --------------- <? require_once 'Date.php'; $date1 = new Date('2008-06-01T02:00:00'); $date1->setTZByID('EST'); echo $date1->format('%Y-%m-%d %H:%M:%S'), ' ', $date1->tz->id, "<br>"; $date1->convertTZByID("GMT"); echo $date1->format('%Y-%m-%d %H:%M:%S'), ' ', $date1->tz->id, "<br>"; ?> Expected result: ---------------- 2008-06-01 02:00:00 EST 2008-06-01 06:00:00 GMT Actual result: -------------- 2008-06-01 02:00:00 EST 2008-06-01 07:00:00 GMT

Comments

 [2008-07-03 14:51 UTC] gauthierm (Michael Gauthier)
I can confirm this bug exists in 1.5.0a1. Historical dates have their time zone conversions done incorrectly. The rules in Time_Zone.php are only applicable for current dates and no data is available to properly convert dates in the past. For example, any date before 2007 has different daylight time rules for the time zone America/Halifax. Example date 2006-11-03T03:15:00 America/Halifax. This should not be daylight time but is daylight time according the the date class. The reason is the cutoff dates changed in 2007.
 [2008-07-21 13:06 UTC] doconnor (Daniel O'Connor)
Wontfix or needs better documentation?
 [2008-07-21 15:17 UTC] jmarcv (John Ventimiglia)
gauthierm - you modified this to say the bug is with dates in the past, but when the bug was submitted, the date was not in the past only one day. I get the same erroneous results with dates in the near future: --------------- <? require_once 'Date.php'; $date1 = new Date('2008-08-01T02:00:00'); $date1->setTZByID('EST'); echo $date1->format('%Y-%m-%d %H:%M:%S'), ' ', $date1->tz->id, "<br>"; $date1->convertTZByID("GMT"); echo $date1->format('%Y-%m-%d %H:%M:%S'), ' ', $date1->tz->id, "<br>"; ?> Expected result: ---------------- 2008-08-01 02:00:00 EST 2008-08-01 06:00:00 GMT Actual result: -------------- 2008-08-01 02:00:00 EST 2008-08-01 07:00:00 GMT Thus I am re-editing the subject back to the original, and contest the no-fix entry.
 [2008-10-20 21:33 UTC] markeb (Mark Bembnowski)
As far as the first comment to this bug goes (regarding Time Zone DST calculations being incorrect in the past), is it possible to resolve this issue? Do the new core PHP Date/Time functions added in v5.1 suffer this same limitation? If not, I'd recommend that PEAR Date support correct Time Zone and DST calculations in the past, as well (within reason, of course).
 [2008-10-22 20:51 UTC] markeb (Mark Bembnowski)
I have just opened a bug related to having the correct DST rules for dates in the past (as opposed to applying current DST rules for Time Zones regardless of what the DST rules were *at that time*). I have confirmed that PHP v5.1+'s DateTime class handles DST conversion correctly in both the present and past.
 [2008-10-22 20:59 UTC] markeb (Mark Bembnowski)
As an added note on the topic of this bug: Eastern Standard Time has an offset of -05:00. Eastern Daylight Time has an offset of -04:00. EST and EDT are *not* interchangeable, although this is a common misconception. If you want to set the time zone to just "Eastern Time" (with the current DST rules being applied), set the Time Zone to 'America/New_York' (preferred) or 'US/Eastern'. HOWEVER, I *do* think that the PEAR Date class should properly recognize 'Eastern Daylight Time' (and the like) as a time zone, as it currently does not (which hinders the PEAR Date class's ability to auto-detect the current time zone on some systems).