ZF-5789: Wrong calculation for GMT offset in Zend_Date

Issue Type: Bug Created: 2009-02-15T04:39:12.000+0000 Last Updated: 2009-02-19T13:31:01.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Marco Baumgartl (mbaumgartl) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: Attachments:


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.


Posted by Thomas Weidner (thomas) on 2009-02-19T13:30:56.000+0000

Changed with r14117

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.