From: [EMAIL PROTECTED] Operating system: WinXP PHP version: 4.3.0 PHP Bug Type: Date/time related Bug description: Date/Sec bug
When I run this script, it has make an error. While I increment the an date with secsperday, it is make an wrong result ! The example: <?php define("SECSPERMIN",60); define("MINSPERHOUR",60); define("HOURSPERDAY",24); define("SECSPERHOUR",SECSPERMIN*MINSPERHOUR); define("SECSPERDAY",SECSPERHOUR*HOURSPERDAY); function TimeToStr($time){ $str=""; $dt=GetDate($time); $str= sprintf("%02d",$dt['hours']).":".sprintf("%02d",$dt['minutes']).":".sprintf("%02d",$dt['seconds']); return($str); } function DateToStr($date) { $str=""; $dt=GetDate($date); $str=$dt['year'].'.'.sprintf("%02d",$dt['mon']).'.'.sprintf("%02d",$dt['mday']); return($str); }; function DateTimeToStr($datetime) { $r=DateToStr($datetime).' '.TimeToStr($datetime); return($r); } function EncodeDate($y,$m,$d){ #printbr("$y $m $d"); if (!checkdate($m,$d,$y)) return(-1); $res=mktime(0,0,0, $m, $d, $y); return($res) ; } function DecodeDate($date,&$y,&$m,&$d){ $y=-1;$m=-1;$d=-1; $dt=GetDate($date);if($dt===False) return(False); $y=$dt['year']; $m=$dt['mon']; $d=$dt['mday']; } print "<html>\n"; $date=EncodeDate(2003,01,01); for ($i=0;$i<1000;$i++) { DecodeDate($date,$y,$m,$d); $a1=DateTimeToStr($date); $date2=EncodeDate($y,$m,$d); $a2=DateTimeToStr($date); print "$date $a1 <-> $date2 $a2<br>\n"; if (($a1<>$a2) or ($date<>$date2)) {print "!!!! ERROR !!!!<br>\n"; exit;} $date=$date+SECSPERDAY; } print "DONE WITHOUT ERRORS !<br>\n"; print '</html>'; ?> -- Edit bug report at http://bugs.php.net/?id=21933&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=21933&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=21933&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=21933&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=21933&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=21933&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=21933&r=support Expected behavior: http://bugs.php.net/fix.php?id=21933&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=21933&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=21933&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=21933&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21933&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=21933&r=dst IIS Stability: http://bugs.php.net/fix.php?id=21933&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=21933&r=gnused