|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-10-28 11:47 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 14:00:01 2025 UTC |
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