Re: PHP 4.0 Bug #5798: mktime miscalcs 1 hour offset twice a year
| From: | Rasmus Lerdorf | Date: | Wed, 26 Jul 2000 16:08:08 +0000 |
| Subject: | Re: PHP 4.0 Bug #5798: mktime miscalcs 1 hour offset twice a year | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-26323@lists.php.net to get a copy of this message | ||
Seems to me that you have discovered daylight savings time. Try changing
your TZ env variable.
-Rasmus
On 26 Jul 2000 mark.ruys@in2sports.net wrote:
> From: mark.ruys@in2sports.net
> Operating system: FreeBSD 3.4
> PHP version: 4.0.1pl2
> PHP Bug Type: Misbehaving function
> Bug description: mktime miscalcs 1 hour offset twice a year
>
> Twice a year, mktime(0,0,0,$month,$day,$year) returns 3600 seconds too much/to few seconds, as
> the code below shows. This error is reproduced on PHP 3.??.
>
> ...
> 0922658400 1999-03-29 -3600
> 0941410800 1999-11-01 3600
> 0954108000 2000-03-27 -3600
> 0972860400 2000-10-30 3600
> 0985557600 2001-03-26 -3600
> 1004310000 2001-10-29 3600
> 1017612000 2002-04-01 -3600
> 1035759600 2002-10-28 3600
> 1049061600 2003-03-31 -3600
> 1067209200 2003-10-27 3600
> 1080511200 2004-03-29 -3600
> 1099263600 2004-11-01 3600
> ...
>
> <html><body><?php
>
> $prev = 0;
> for ($year=1970 ; $year < 2038 ; $year++)
> {
> for ($month=1 ; $month <= 12; $month++)
> {
> switch ($month)
> {
> case 4: case 6: case 9: case 11:
> $days = 30;
> break;
> case 2:
> $days = (($year % 4 == 0) && ($year % 100 != 0) ? 29 : ($year % 400 == 0) ? 29 :
> 28);
> break;
> default:
> $days = 31;
> }
> for ($day=1 ; $day <= $days; $day++)
> {
> $date = mktime(0,0,0,$month,$day,$year);
> if ( $prev != 0 && $prev + 86400 != $date )
> {
> printf("%010d %d-%02d-%02d
> %d<br>\n",$date,$year,$month,$day,$date-$prev-86400);
> }
> $prev = $date;
> }
> }
> }
>
> ?></body>
>
>
>
>