php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5798 mktime miscalcs 1 hour offset twice a year
Submitted: 2000-07-26 17:50 UTC Modified: 2000-07-26 19:05 UTC
From: mark dot ruys at in2sports dot net Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: FreeBSD 3.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mark dot ruys at in2sports dot net
New email:
PHP Version: OS:

 

 [2000-07-26 17:50 UTC] mark dot ruys at in2sports dot net
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>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-26 19:05 UTC] rasmus@php.net
User forgot about daylight savings time
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 13:00:01 2026 UTC