php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
Status: Closed Package: Date/time related
PHP Version: 5.3CVS-2008-07-16 (CVS) OS: Mac OS X
Private report: No CVE-ID:
 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-16 15:42 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 08:02:33 2014 UTC