#46211 [Opn->Bgs]: strtotime give wrong result when DST changes
| From: | jani@php.net | Date: | Wed, 01 Oct 2008 23:56:48 +0000 |
| Subject: | #46211 [Opn->Bgs]: strtotime give wrong result when DST changes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129404@lists.php.net to get a copy of this message | ||
ID: 46211
Updated by: jani@php.net
Reported By: cmt042 at motorola dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: UNIX
PHP Version: 5.2.6
New Comment:
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which
do
not suffer from DST.
Previous Comments:
------------------------------------------------------------------------
[2008-10-01 15:19:04] cmt042 at motorola dot com
Description:
------------
When DST changes, the strtotime function give back wrong result.
Reproduce code:
---------------
// Need to adjust the day or hour numbers when run the code to make it
cross the DST, Mar 8th 2:00AM 2009
$output = array();
for ($i = 15; $i <=19; $i++)
{
$t = strtotime("+157 days +${i} hours");
$output[] = date("r",$t);
}
foreach ($output as $line)
print $line . "\n";
Expected result:
----------------
Sun, 08 Mar 2009 00:54:09 -0600
Sun, 08 Mar 2009 01:54:09 -0600
Sun, 08 Mar 2009 03:54:09 -0500
Sun, 08 Mar 2009 04:54:09 -0500
Sun, 08 Mar 2009 05:54:09 -0500
Actual result:
--------------
Sun, 08 Mar 2009 00:54:09 -0600
Sun, 08 Mar 2009 01:54:09 -0600
Sun, 08 Mar 2009 03:54:09 -0500
Sun, 08 Mar 2009 03:54:09 -0500
Sun, 08 Mar 2009 04:54:09 -0500
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46211&edit=1