php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19875 date/strtotime fails around time change
Submitted: 2002-10-11 21:36 UTC Modified: 2002-10-12 07:03 UTC
From: beryrinaldo at mac dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 + 41 = ?
Subscribe to this entry?

 
 [2002-10-11 21:36 UTC] beryrinaldo at mac dot 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-11 21:37 UTC] beryrinaldo at mac dot com
Updated summary line.
 [2002-10-11 21:53 UTC] 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-12 00:19 UTC] beryrinaldo at mac dot com
I know it's daylight savings time, but why doesn't 
strtotime deal with it properly?
 [2002-10-12 07:03 UTC] derick@php.net
strtotime is ok, mktime is affected... use gmmktime.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC