ID: 21212
User updated by: [EMAIL PROTECTED]
-Summary: strtotime fails when crossing year
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Date/time related
Operating System: linux
PHP Version: 4.2.3
New Comment:
-
Previous Comments:
------------------------------------------------------------------------
[2002-12-27 08:22:26] [EMAIL PROTECTED]
/* 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>";
}
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21212&edit=1