Edit report at https://bugs.php.net/bug.php?id=62185&edit=1
ID: 62185
Comment by: riptide dot tempora at opinehub dot com
Reported by: omg00dness at yahoo dot com
Summary: strtotime() returns incorrect time around DST
(America)
Status: Open
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: 5.3.13
Block user comment: N
Private report: N
New Comment:
Improved test script:
<?php
date_default_timezone_set('America/Los_Angeles');
echo strtotime("2012-03-11 5:00:00 -1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 5:00:00 -1 hour")) . "\n";
echo strtotime("2012-03-11 4:00:00 -1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 4:00:00 -1 hour")) . "\n";
echo strtotime("2012-03-11 3:00:00 -1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 3:00:00 -1 hour")) . "\n";
echo strtotime("2012-03-11 3:01:00 -1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 3:01:00 -1 hour")) . "\n";
echo strtotime("2012-03-11 2:59:00 -1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 2:59:00 -1 hour")) . "\n";
echo strtotime("2012-03-11 1:00:00 +1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 1:00:00 +1 hour")) . "\n";
echo strtotime("2012-03-11 0:00:00 +1 hour") . "\t";
echo date("M j Y H:i:s I", strtotime("2012-03-11 0:00:00 +1 hour")) . "\n";
?>
My server produced (PHP Version 5.3.13):
1331463600 Mar 11 2012 04:00:00 1
1331460000 Mar 11 2012 03:00:00 1
1331460000 Mar 11 2012 03:00:00 1
1331460060 Mar 11 2012 03:01:00 1
1331459940 Mar 11 2012 01:59:00 0
1331460000 Mar 11 2012 03:00:00 1
1331456400 Mar 11 2012 01:00:00 0
http://www.alpha7f.com/phpt/bug62185.php
Previous Comments:
------------------------------------------------------------------------
[2012-05-29 23:07:58] omg00dness at yahoo dot com
Description:
------------
For an American timezone (at least those that observe Daylight Savings Time),
strtotime() is outputting incorrectly when adding a negative time string.
Example uses March 11, 2012 at 2:00am, where the local time jumps instead to
3:00am.
Test script:
---------------
<?php
date_default_timezone_set('America/Los_Angeles');
echo date("M j Y H:i:s I", strtotime("2012-03-11 5:00:00 -1 hour")) . "\n";
echo date("M j Y H:i:s I", strtotime("2012-03-11 4:00:00 -1 hour")) . "\n";
echo date("M j Y H:i:s I", strtotime("2012-03-11 3:00:00 -1 hour")) . "\n";
echo date("M j Y H:i:s I", strtotime("2012-03-11 3:01:00 -1 hour")) . "\n";
echo date("M j Y H:i:s I", strtotime("2012-03-11 2:59:00 -1 hour")) . "\n";
echo date("M j Y H:i:s I", strtotime("2012-03-11 1:00:00 +1 hour")) . "\n";
echo date("M j Y H:i:s I", strtotime("2012-03-11 0:00:00 +1 hour")) . "\n";
?>
Expected result:
----------------
Mar 11 2012 04:00:00 1
Mar 11 2012 03:00:00 1
Mar 11 2012 01:00:00 0
Mar 11 2012 01:01:00 0
Dec 31 1969 16:00:00 0 //Perhaps output false?
Mar 11 2012 03:00:00 1
Mar 11 2012 01:00:00 0
Actual result:
--------------
Mar 11 2012 04:00:00 1
Mar 11 2012 03:00:00 1
Mar 11 2012 03:00:00 1
Mar 11 2012 03:01:00 1
Mar 11 2012 01:59:00 0
Mar 11 2012 03:00:00 1
Mar 11 2012 01:00:00 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62185&edit=1