ID: 30532
User updated by: rbro at hotmail dot com
Reported By: rbro at hotmail dot com
-Status: Feedback
+Status: Open
Bug Type: Date/time related
Operating System: Linux
PHP Version: 4.3.9
New Comment:
Thanks - I just tried it using php4-STABLE-200502051730, but I seem to
be still getting the same result. My test script is:
<?php
echo date('Y-m-d H:i:s', strtotime('2004-10-31 +2 hours'))."\n";
echo date('Y-m-d H:i:s', strtotime('+2 hours',
strtotime('2004-10-31')))."\n";
?>
The output I am getting is:
2004-10-31 02:00:00
2004-10-31 01:00:00
while I expected to get:
2004-10-31 01:00:00
2004-10-31 01:00:00
Previous Comments:
------------------------------------------------------------------------
[2005-02-03 04:47:46] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2004-10-22 22:32:27] rbro at hotmail dot com
Further information: The following script does give the expected
results:
<?php
echo date('Y-m-d H:i:s', strtotime('+1 hour',
strtotime('2004-10-31')))."\n";
echo date('Y-m-d H:i:s', strtotime('+2 hours',
strtotime('2004-10-31')))."\n";
echo date('Y-m-d H:i:s', strtotime('+3 hours',
strtotime('2004-10-31')))."\n";
?>
of
2004-10-31 01:00:00
2004-10-31 01:00:00
2004-10-31 02:00:00
So now I believe the issue is that the following 2 statements give
different output though they should have the same output:
<?php
echo strtotime('2004-10-31 +2 hours')."\n";
echo strtotime('+2 hours', strtotime('2004-10-31'))."\n";
?>
------------------------------------------------------------------------
[2004-10-22 17:33:21] rbro at hotmail dot com
Description:
------------
In the US, Daylight Savings Time ends on October 31, 2004 at 2am where
clocks are then reset back to 1am. I am in the Eastern time zone. If
I run the following script where I'm adding 1 hour, 2 hours, and 3
hours to the date 2004-10-31, I'm getting different results from
including EDT in the date or not, when I thought that strtotime()
defaults to the local timezone.
Reproduce code:
---------------
<?php
echo date('Y-m-d H:i:s', strtotime('2004-10-31 EDT +1 hour'))."\n";
echo date('Y-m-d H:i:s', strtotime('2004-10-31 EDT +2 hours'))."\n";
echo date('Y-m-d H:i:s', strtotime('2004-10-31 EDT +3 hours'))."\n";
echo "\n";
echo date('Y-m-d H:i:s', strtotime('2004-10-31 +1 hour'))."\n";
echo date('Y-m-d H:i:s', strtotime('2004-10-31 +2 hours'))."\n";
echo date('Y-m-d H:i:s', strtotime('2004-10-31 +3 hours'))."\n";
?>
Expected result:
----------------
2004-10-31 01:00:00
2004-10-31 01:00:00
2004-10-31 02:00:00
2004-10-31 01:00:00
2004-10-31 01:00:00
2004-10-31 02:00:00
Actual result:
--------------
2004-10-31 01:00:00
2004-10-31 01:00:00
2004-10-31 02:00:00
2004-10-31 01:00:00
2004-10-31 02:00:00
2004-10-31 03:00:00
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30532&edit=1