|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-16 15:42 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Description: ------------ If you generate a DateTimeZone with new and one with date_create()->getTimeZone, the resulting DateTimeZone objects behave different even if the are of the same time zone. Reproduce code: --------------- $tz1 = new DateTimeZone('UTC'); $tz2 = date_create('UTC')->getTimeZone(); echo $tz1->getName(), PHP_EOL; echo $tz2->getName(), PHP_EOL; $d = new DateTime('2008-01-01 12:00:00+0200'); $d->setTimeZone($tz1); echo $d->format(DATE_ISO8601), PHP_EOL; $d = new DateTime('2008-01-01 12:00:00+0200'); $d->setTimeZone($tz2); echo $d->format(DATE_ISO8601), PHP_EOL; Expected result: ---------------- UTC UTC 2008-1-1T10:00:00+0000 2008-1-1T10:00:00+0000 Actual result: -------------- UTC UTC 2008-01-01T10:00:00+0000 PHP Warning: DateTime::setTimezone(): Can only do this for zones with ID for now in /Users/tobias/test.php on line 9 Warning: DateTime::setTimezone(): Can only do this for zones with ID for now in /Users/tobias/test.php on line 9 2008-01-01T12:00:00+0200