#41912 [Asn->Bgs]: date() interprets Unix timestamp as GMT and converts it to the default timezone
| From: | derick@php.net | Date: | Wed, 11 Jul 2007 21:02:56 +0000 |
| Subject: | #41912 [Asn->Bgs]: date() interprets Unix timestamp as GMT and converts it to the default timezone | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114936@lists.php.net to get a copy of this message | ||
ID: 41912
Updated by: derick@php.net
Reported By: ron@php.net
-Status: Assigned
+Status: Bogus
Bug Type: Date/time related
Operating System: Debian GNU/Linux
PHP Version: 5.2.3
Assigned To: derick
New Comment:
I checked this now, and it is not a bug. If you convert to a timestamp
there is no more associated timezone possible. The date object keeps
this normally - but it's impossible to attach this just to a number.
If you add the timezone as output, you will see the difference:
<?php
date_default_timezone_set('Europe/Amsterdam');
$date = new DateTime('now', new DateTimeZone('GMT'));
echo 'DateTime::format(): '.$date->format('Ymd, H:i:s T')."\n";
echo 'date() of unixtime: '.date('Ymd, H:i:s T',
$date->format('U'))."\n";
?>
derick@kossu:~$ php bug41912.php
DateTime::format(): 20070711, 21:00:26 UTC
date() of unixtime: 20070711, 23:00:26 CEST
Previous Comments:
------------------------------------------------------------------------
[2007-07-06 08:21:10] ron@php.net
Description:
------------
date() interprets a Unix timestamp as GMT and converts it to the
default timezone. In my opinion it should not convert timezones.
(bug report requested by Derick Rethans).
Reproduce code:
---------------
<?php
date_default_timezone_set('Europe/Amsterdam');
$date = new DateTime('now', new DateTimeZone('GMT'));
echo 'DateTime::format(): '.$date->format('Ymd, H:i:s')."\n";
echo 'date() of unixtime: '.date('Ymd, H:i:s',
$date->format('U'))."\n";
?>
Expected result:
----------------
DateTime::format(): 20070706, 07:38:45
date() of unixtime: 20070706, 07:38:45
Actual result:
--------------
DateTime::format(): 20070706, 07:38:45
date() of unixtime: 20070706, 09:38:45
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41912&edit=1