#43548 [Opn->Bgs]: date() returns incorrect time by +1 hour
| From: | derick@php.net | Date: | Mon, 10 Dec 2007 10:15:20 +0000 |
| Subject: | #43548 [Opn->Bgs]: date() returns incorrect time by +1 hour | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120522@lists.php.net to get a copy of this message | ||
ID: 43548
Updated by: derick@php.net
Reported By: andrew at confirmalert dot com dot au
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Win 2003 Server SP2
PHP Version: 5.2.5
New Comment:
Exactly, and that is why you need to set it:
http://no2.php.net/manual/en/ref.datetime.php#ini.date.timezone
(Set it to: Africa/Casablanca)
PHP will also warn you about this if you have E_STRICT errors turned
on. This is not a bug.
Previous Comments:
------------------------------------------------------------------------
[2007-12-10 10:05:33] andrew at confirmalert dot com dot au
Answer 1.
=========
The output for PHP 5.2.5 is:
---------
C:\php-5.2.5>php test2.php
Europe/London
---------
Answer 2.
=========
The output for php 5.2.5 of 2007-09-24 @ 11:00 is accurate for
Europe/London.
The output for php 5.2.5 is inaccurate for Morroco/Casablanca which is
the timezone that the server has been set to i.e. London was observing
daylight savings time on the above date. Casablanca was not (2007-09-24
@ 10:00). See the following link for details ...
http://www.timeanddate.com/worldclock/fixedtime.html?month=9&day=24&year=2007&hour=10&min=0&sec=0&p1=0
It appears that php 5.2.5 does not accurately pickup the timezone set
by the Windows operating system.
------------------------------------------------------------------------
[2007-12-10 08:16:05] derick@php.net
Please answer my questions:
1. What is the output of:
<?php
echo date_default_timezone_get(), "\n";
?>
2. What is wrong with the PHP 5.2.5 output?
------------------------------------------------------------------------
[2007-12-09 23:01:36] andrew at confirmalert dot com dot au
Hi Derick.
PHP versions up to 5.0.3 were producing a result of '2007-09-24 @
10:00'. PHP 5.2.5 produces '2007-09-24 @ 11:00' which +1 hour
difference. This breaks our online diary system.
Cheers.
Andrew
------------------------------------------------------------------------
[2007-12-09 22:23:24] derick@php.net
What is wrong with the PHP 5.2.5 output?
------------------------------------------------------------------------
[2007-12-09 22:00:21] andrew at confirmalert dot com dot au
Description:
------------
OK. I can reproduce this bug. The previous ticket was closed
prematurely and with an incorrect status. So there is no doubt or
miscommunication I have re-run the test on the same machine using the
two versions of PHP. The results are the still the same as originally
reported in bug '42755 date() returns incorrect time by +1 hour'.
Reproduce code:
---------------
======
code - test1.php
======
<?php
echo date("Y-m-d @ g:i", 1190671200);
?>
Expected result:
----------------
======
result using php 5.0.3
======
C:\PHP>php test1.php
2007-09-24 @ 10:00
C:\PHP>php --version
PHP 5.0.3 (cli) (built: Dec 15 2004 08:07:57)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
Actual result:
--------------
======
result using php 5.2.5
======
C:\php-5.2.5>php test1.php
2007-09-24 @ 11:00
C:\php-5.2.5>php --version
PHP 5.2.5 (cli) (built: Nov 8 2007 23:18:51)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43548&edit=1