#21933 [Opn->Bgs]: Date/Sec bug
| From: | derick@php.net | Date: | Wed, 29 Jan 2003 19:06:09 +0000 |
| Subject: | #21933 [Opn->Bgs]: Date/Sec bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-31609@lists.php.net to get a copy of this message | ||
ID: 21933
Updated by: derick@php.net
Reported By: kepesk@peto.hu
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: WinXP
PHP Version: 4.3.0
New Comment:
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which
do
not suffer from DST.
not a bug -> bogus
Previous Comments:
------------------------------------------------------------------------
[2003-01-29 13:01:08] michael.mauch@gmx.de
When I run your script, it exits at this line:
1049065200 2003.03.31 01:00:00 <-> 1049061600 2003.03.31 01:00:00
!!!! ERROR !!!!
As you can see on <http://greenwichmeantime.com/local/europe/hu.htm>,
March 30th does not have 24*60*60 seconds, because that's when Hungary
switches to daylight savings time.
------------------------------------------------------------------------
[2003-01-29 03:48:44] kepesk@peto.hu
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 this bug report at http://bugs.php.net/?id=21933&edit=1