php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29065 Some wrong dates when using gtdate()/mktime()
Submitted: 2004-07-08 18:49 UTC Modified: 2004-07-09 08:03 UTC
From: ehavet at yahoo dot fr Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.6 OS: Linux 2.4.16C12
Private report: No CVE-ID: None
 [2004-07-08 18:49 UTC] ehavet at yahoo dot fr
Description:
------------
When you want to display each 10/31/Year plus 1 day, you've got sometimes 10/31/Year instead of 11/01/Year.

Noticed on PHP 4.3.3 (ISP linux server) and PHP 4.3.6 (WinXP personal system)

Getting the date with date("m/d/Y", mktime(0,0,0,10,31,$i)+(24*3600)); gives the same result exept for 11/1/1993

Reproduce code:
---------------
<?php
  
  for ($i = 1990 ;$i < 2011 ; $i++) {
    
        $date = getdate(mktime(0,0,0,10,31,$i)+(24*3600));
        echo $date['mon']."/".$date['mday']."/".$date['year']."\n";

  }
  
?>

Expected result:
----------------
11/1/1990
11/1/1991
11/1/1992
11/1/1993
11/1/1994
11/1/1995
11/1/1996
11/1/1997
11/1/1998
11/1/1999
11/1/2000
...


Actual result:
--------------
11/1/1990
11/1/1991
11/1/1992
10/31/1993
11/1/1994
11/1/1995
11/1/1996
11/1/1997
11/1/1998
10/31/1999
11/1/2000
11/1/2001
11/1/2002
11/1/2003
10/31/2004
11/1/2005
11/1/2006
11/1/2007
11/1/2008
11/1/2009
10/31/2010
11/1/2011


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-08 20:22 UTC] pollita@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.


 [2004-07-08 21:22 UTC] ehavet at yahoo dot fr
Daylight savings OK

That means it occurs every 6 years (daylight savings & leap year). But :

1- using getdate()
1993 -> 1999 => 6 years
1999 -> 2004 => 5 years
2004 -> 2010 => 6 years

2- using date()
1993 => not noticed
1999 -> 2004 => 5 years
2004 => 2010 => 6 years

There is not regular interval. I don't understand
 [2004-07-08 21:51 UTC] ehavet at yahoo dot fr
OK, the daylight savings is the reason.

Thank you and sorry about that
 [2004-07-09 08:03 UTC] tony2001@php.net
not a bug -> bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 09:01:29 2024 UTC