From: tj at systisoft dot com
Operating system: Mac OS X
PHP version: 5.3CVS-2008-07-17 (CVS)
PHP Bug Type: Date/time related
Bug description: DateTime::setTimezone kann not set timezones without ID
Description:
------------
if you set a time zone for a DateTime via DateTime::setTimeZone() and that
time zone has no ID you get an error message and the time zone will not be
set.
This can lead to Problems if you have two DateTime objects from a surce
you do not control and want to format the secont DateTime object in the
same time zone as the first.
Reproduce code:
---------------
$d1 = new DateTime('2008-01-01 12:00:00 +02:00');
$d2 = new DateTime('2008-01-01 12:00:00 UTC');
echo $d1->format(DATE_ISO8601), PHP_EOL;
echo $d2->format(DATE_ISO8601), PHP_EOL;
$d2->setTimeZone($d1->getTimeZone());
echo $d1->format(DATE_ISO8601), PHP_EOL;
echo $d2->format(DATE_ISO8601), PHP_EOL;
Expected result:
----------------
2008-01-01T12:00:00+0200
2008-01-01T12:00:00+0000
2008-01-01T12:00:00+0200
2008-01-01T14:00:00+0200
Actual result:
--------------
2008-01-01T12:00:00+0200
2008-01-01T12:00:00+0000
PHP Warning: DateTime::setTimezone(): Can only do this for zones with ID
for now in /Users/tobias/test.php on line 5
Warning: DateTime::setTimezone(): Can only do this for zones with ID for
now in /Users/tobias/test.php on line 5
2008-01-01T12:00:00+0200
2008-01-01T12:00:00+0000
--
Edit bug report at http://bugs.php.net/?id=45543&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45543&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45543&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45543&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45543&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45543&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45543&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45543&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45543&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45543&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45543&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45543&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45543&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45543&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45543&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45543&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45543&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45543&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45543&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45543&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45543&r=mysqlcfg