ZF-5789: Wrong calculation for GMT offset in Zend_Date
Description
I have found a bug in the getGmtOffset() method of Zend_Date.
I try to get the current (2009/02/15) GMT offset to New Zealand timezone using the following code:
$date = new Zend_Date(); $date->setTimezone('Pacific/Auckland'); $offset = $date->getGmtOffset();
The offset variable contains now -43200 seconds (or -12 hours).
Trying to get the offset using plain PHP:
date_default_timezone_set('Pacific/Auckland'); $localtime = localtime(time(), true); $offset = mktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 1, $localtime['tm_mday'], $localtime['tm_year'] + 1900) - gmmktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 1, $localtime['tm_mday'], $localtime['tm_year'] + 1900);
The offset variable contains now -46800 seconds (or -13 hours). This version pays attention to the summer-/wintertime while the getGmtOffset() method always calculates a fixed offset. I think Zend_Date's method should do the same.
Comments
Posted by Thomas Weidner (thomas) on 2009-02-19T13:30:56.000+0000
Changed with r14117