#19875 [Bgs]: date/strtotime fails around time change
ID: 19875
Updated by: derick@php.net
Reported By: beryrinaldo@mac.com
Status: Bogus
Bug Type: Date/time related
Operating System: Linux
PHP Version: 4.2.3
New Comment:
strtotime is ok, mktime is affected... use gmmktime.
Derick
Previous Comments:
------------------------------------------------------------------------
[2002-10-12 00:19:29] beryrinaldo@mac.com
I know it's daylight savings time, but why doesn't
strtotime deal with it properly?
------------------------------------------------------------------------
[2002-10-11 21:53:26] sniper@php.net
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
------------------------------------------------------------------------
[2002-10-11 21:37:26] beryrinaldo@mac.com
Updated summary line.
------------------------------------------------------------------------
[2002-10-11 21:36:26] beryrinaldo@mac.com
Here is a short script:
<?php
$goodday = mktime(0,0,0,10,20,2002);
$goodsun = strtotime("Sun",$goodday);
$goodmon = strtotime("Mon",$goodday);
$gooddif = $goodmon - $goodsun;
$goodsunstr = date("Ymd.Hi",$goodsun);
$goodmonstr = date("Ymd.Hi",$goodmon);
print "$goodday $gooddif $goodsunstr $goodmonstr <br>\n";
$okday = mktime(0,0,0,10,27,2002);
$oksun = strtotime("Sun",$okday);
$badmon = strtotime("Mon",$okday);
$okdif = $badmon - $oksun;
$oksunstr = date("Ymd.Hi",$oksun);
$badmonstr = date("Ymd.Hi",$badmon);
print "$okday $okdif $oksunstr $badmonstr <br>\n";
echo "PHP version " . phpversion() . " <br>\n";
?>
The output of the script is this:
1035097200 86400 20021020.0000 20021021.0000
1035702000 86400 20021027.0000 20021027.2300
PHP version 4.2.3
Although the difference between Sunday (Oct 27) and Monday is 24 hours,
the output from date shows it to be only 23.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19875&edit=1
Thread (5 messages)