php.net |  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 (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.5 OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mattis at xait dot no
New email:
PHP Version: OS:

 

 [2007-12-07 09:55 UTC] mattis at xait dot no
Description:
------------
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:
---------------
<?php
date_default_timezone_set("Etc/GMT+1");
$datetime = new DateTime('Fri, 07 Dec 2007 19:05:14 +1000');
echo $datetime->getTimezone()->getName(), "\n";

Expected result:
----------------
Etc/GMT-10

Actual result:
--------------
Etc/GMT+1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-07 09:59 UTC] derick@php.net
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] 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.

The script now returns:
+10:00
(And you really should not be using the "Etc/*" style timezone identifiers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 18:01:30 2024 UTC