|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-12-30 04:04 UTC] o dot oudry at voila dot fr
[2002-12-30 12:45 UTC] pollita@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
/* function strftime produce wrong result with a timestamp close to the end of Year,the four digit year value is sometimes 1 year after (see "30/12/2002") and sometimes 1 year before (see "01/01/2005") the good one. hope this help */ $dateTab=array(); $dateTab[0] = "Dec 29 2001"; $dateTab[1] = "Dec 30 2001"; $dateTab[2] = "Dec 31 2001"; wrong output with strftime $dateTab[3] = "Jan 01 2002"; $dateTab[4] = "Dec 29 2002"; $dateTab[5] = "Dec 30 2002"; wrong output with strftime $dateTab[6] = "Dec 31 2002"; wrong output with strftime $dateTab[7] = "Jan 01 2003"; $dateTab[8] = "Dec 28 2003"; $dateTab[9] = "Dec 29 2003"; wrong output with strftime $dateTab[10] = "Dec 30 2003"; wrong output with strftime $dateTab[11] = "Dec 31 2003"; wrong output with strftime $dateTab[12] = "Jan 01 2004"; $dateTab[13] = "Dec 28 2004"; $dateTab[14] = "Dec 29 2004"; $dateTab[15] = "Dec 30 2004"; $dateTab[16] = "Dec 31 2004"; $dateTab[17] = "Jan 01 2005"; wrong output with strftime $dateTab[18] = "Jan 02 2005"; wrong output with strftime $dateTab[19] = "Jan 03 2005"; $dateTab[20] = "Jan 04 2005"; $dateTab[21] = "Jan 05 2005"; foreach($dateTab as $currentDate) { if (($timestamp = strtotime($currentDate)) === -1) { echo "The string ($currentDate) is bogus"; } else { $result[0] = date('d/m/Y',$timestamp); $result[1] = strftime("%d/%m/%G",$timestamp); if($result[1] == $result[0]) { echo "$currentDate == $result[0] == $result[1]<br>"; } else { echo "$currentDate == $result[0] != <font color=red>$result[1]</font><br>"; } } }