#26009 [Opn->Bgs]: mktime calc fails on specific dates
| From: | sniper@php.net | Date: | Tue, 28 Oct 2003 16:47:02 +0000 |
| Subject: | #26009 [Opn->Bgs]: mktime calc fails on specific dates | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-49579@lists.php.net to get a copy of this message | ||
ID: 26009
Updated by: sniper@php.net
Reported By: nic at nicskitt dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Windows XP Pro SP1, IIS, ISAPI
PHP Version: 4.3.3
New Comment:
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.
..
Previous Comments:
------------------------------------------------------------------------
[2003-10-27 14:43:51] nic at nicskitt dot co dot uk
Description:
------------
When performing the while loop shown in the code mktime function
produces duplicate results on the following specific dates (2004-03-27)
and (2003-03-29) and (2002-03-30). They all seem to be in the month of
march. This starts afer 2001 and I havent yet checked how far it
continues.
Because mktime is suppose to handle illegal days and therefore
recalcuate the whole date I cant see why this would happen.
Reproduce code:
---------------
$starting = strtotime("2001-01-01");
$ending = strtotime("2005-01-01");
$newdate = $starting;
$day = date("d",$newdate);
$month = date("m",$newdate);
$year = date("Y",$newdate);
echo("Starting->".date("Y-m-d",$newdate)."<br>");
echo("Ending->".date("Y-m-d",$ending)."<br>");
$x = 0;
while($newdate<$ending){
$newdate = mktime(0,0,0,$month,($day+$x),$year);
$fulldate = date("Y-m-d",$newdate);
echo($fulldate."<br>");
$x ++;
}
Expected result:
----------------
Relevant Areas...
2002-03-29
2002-03-30 <- just one as you would expect
2002-04-01
2002-04-02
2002-04-03
...skip output...
2003-03-27
2003-03-28
2003-03-29 <- Just one as you would expect
2003-03-31
2003-04-01
and so on...
Actual result:
--------------
Relevant Areas...
2002-03-28
2002-03-29
2002-03-30
2002-03-30 <- Duplicate Date
2002-04-01
2002-04-02
...skip output...
2003-03-27
2003-03-28
2003-03-29
2003-03-29 <- Duplicate Date
2003-03-31
2003-04-01
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26009&edit=1