|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43527 DateTime created from a timestamp reports environment timezone
Submitted: 2007-12-07 09:55 UTC Modified: 2008-01-17 18:52 UTC
From: mattis at xait dot no Assigned: derick
Status: Closed Package: Date/time related
PHP Version: 5.2.5 OS: Windows XP SP2
Private report: No CVE-ID:
 [2007-12-07 09:55 UTC] mattis at xait dot no
When creating a DateTime from a timestamp (i.e. date('r)) it will report the TimeZone of the environment it was created in and not the timezone in the timestamp.

Reproduce code:
$datetime = new DateTime('Fri, 07 Dec 2007 19:05:14 +1000');
echo $datetime->getTimezone()->getName(), "\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-07 09:59 UTC]
There is a bug here, but the expected result is not necessarily what you say it should be. Because there is no real timezone , it probably should return false.
 [2008-01-17 18:52 UTC]
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
Thank you for the report, and for helping us make PHP better.

The script now returns:
(And you really should not be using the "Etc/*" style timezone identifiers.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 20:01:34 2015 UTC