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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: beryrinaldo at mac dot com
New email:
PHP Version: OS:

 

 [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 04 16:01:31 2024 UTC