Saturday, February 26, 2011

BUG: Zend_Date changes automatically the timezone after setting the unix timestamp to -100000000

Wanted to outline a very interesting bug found in Zend_Date component. After settings  the timestamp to -100000000 it changes the timezone.

ini_set('date.timezone', 'UTC');

$date = new Zend_Date();
$date->setTimezone('Europe/Berlin');
$date->set(-100000000);
 
So you will receive:
Zend_Date Object
(
[_locale:private] => de
[_fractional:private] => 0
[_precision:private] => 3
[_unixTimestamp:private] => -100000000
[_timezone:private] => Etc/GMT+10
[_offset:private] => 36000
[_syncronised:private] => 0
[_dst:protected] => 1
)
 
If you will set the timestamp to -99999999 it works as expected.
So the workaround is to set the timezone after you will set your timestamp.

Check out details  on Zend_Date changes automatically the timezone after setting the unix timestamp.

No comments:

Post a Comment