Bug #15029: mktime bug
| From: | bruno at aries dot lu | Date: | Mon, 14 Jan 2002 14:50:19 +0000 |
| Subject: | Bug #15029: mktime bug | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-77019@lists.php.net to get a copy of this message | ||
From: bruno@aries.lu
Operating system: Windows NT
PHP version: 4.0.6
PHP Bug Type: *General Issues
Bug description: mktime bug
The underlying code produces a bug in the time calculation of "mktime". The
28th October 2001 has got 25 hours!!!
<?
function string2date($dat)
{
$resu = substr($dat,6,4).substr($dat,3,2).substr($dat,0,2);
return $resu;
};
$date = "25.10.2001";
$stDate4 = "30.10.2001";
$day = substr($date,0,2);
$month = substr($date,3,2);
$year = substr($date,6,4);
$current_date = mktime (0,0,0,$month,$day,$year);
while ($date != $stDate4)
{
// add 1 day = 86400 seconds to the timestamp
$current_date = $current_date + 86400;
$date = date ("d.m.Y",$current_date);
$Date = string2date($date);
/* // this overrides the bug
if ($first_date == $Date)
{
$current_date = $current_date + 86400;
$date = date ("d.m.Y",$current_date);
$Date = string2date($date);
}
*/
echo "$Date<br>";
}
?>
--
Edit bug report at: http://bugs.php.net/?id=15029&edit=1