|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-22 17:33 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 13:00:01 2025 UTC |
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"; ?>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