new DateTimeZone() and date_create()->getTimezone() behave diffent
| Bug #45529 | new DateTimeZone() and date_create()->getTimezone() behave diffent | ||||
|---|---|---|---|---|---|
| Submitted: | 2008-07-16 13:40 UTC | Modified: | 2008-07-16 15:42 UTC | ||
| From: | tj at systisoft dot com | Assigned: | derick (profile) | ||
| Status: | Closed | Package: | Date/time related | ||
| PHP Version: | 5.3CVS-2008-07-16 (CVS) | OS: | Mac OS X | ||
| Private report: | No | CVE-ID: | None | ||
[2008-07-16 13:40 UTC] tj at systisoft dot com
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-07-16 15:42 UTC] derick@php.net