php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42376 error between date and mktime
Submitted: 2007-08-22 10:34 UTC Modified: 2007-08-22 11:36 UTC
From: piefra at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.3 OS: bof win(5) & linux(4.1)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: piefra at gmail dot com
New email:
PHP Version: OS:

 

 [2007-08-22 10:34 UTC] piefra at gmail dot com
Description:
------------
(sorry for my english i'm french )
using timestamp incrementation with date(H), i found somme datetime error : 
the error occur on the same hours ( 02:00 ) 

echo date("Y/m/d H:i",gmmktime(2,0,0,03,25,2007)) -> 2007/03/25 03:00

reproductible on every years same month ( end mars ) 
2007/03/25 03:00,2008/03/30 03:00,2009/03/29 03:00,2010/03/28 03:00
2011/03/27 03:00,2012/03/25 03:00,2013/03/31 03:00,2014/03/30 03:00
2015/03/29 03:00 ...

to find date errors run the code 

found on windows/wamp 1.5.0 (php 5.1)
tested on linux/mandriva/appache with php 4.1
all plateform test is x86 

Reproduce code:
---------------
<?php
session_cache_expire (0);
echo '<pre>';
  $dt1=mktime(0,0,0,1,1,2007);
  echo date("Y/m/d H:i",$dt1)."\n";
  for ($i=1;$i<24*365*20;$i++){
    set_time_limit(0);
    $dt2=mktime(date("H",$dt1)+1,date("i",$dt1),0,date("m",$dt1),date("d",$dt1),date("Y",$dt1));
    $d=date("H",$dt2)-date("H",$dt1);
    if ($d<>1 and $d <>-23) {
        echo date("Y/m/d H:i",$dt1)." ".date("Y/m/d H:i",$dt2)."\n";
    flush();
    }
    $dt1=$dt2;
  }
  echo date("Y/m/d H:i",$dt2)."\n";
echo '<pre>';
?>


Expected result:
----------------
echo date("Y/m/d H:i",gmmktime(2,0,0,03,25,2007)) -> 2007/03/25 02:00

Actual result:
--------------
echo date("Y/m/d H:i",gmmktime(2,0,0,03,25,2007)) -> 2007/03/25 03:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-22 11:22 UTC] piefra at gmail dot com
sorry im ' done a  wrote error

the exact fonction is mktime (not gmmktime )

expected result: 
echo date("Y/m/d H:i",mktime(2,0,0,03,25,2007)) -> 2007/03/25 02:00

actual result:
echo date("Y/m/d H:i",mktime(2,0,0,03,25,2007)) -> 2007/03/25 03:00
 [2007-08-22 11:23 UTC] derick@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
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.


 [2007-08-22 11:36 UTC] piefra at gmail dot com
oh yes ...

i did'nt know what DST means , now it's done
thanks for to take care of my knowledge.

sorry for the improductive spend time 

piefra
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Nov 30 18:00:01 2025 UTC