php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27852 mktime does not work when DST kicks in
Submitted: 2004-04-03 05:24 UTC Modified: 2004-04-03 07:16 UTC
From: neil dot walker at syntegra dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS: any
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: neil dot walker at syntegra dot com
New email:
PHP Version: OS:

 

 [2004-04-03 05:24 UTC] neil dot walker at syntegra dot com
Description:
------------
Hello,

The following code

Code:

<?php
   $n=date("w",mktime(0,0,0,3,29,2004));
   echo "<pre>";
   for($i=1;$i<32;$i++)
   {
      $d=date("D dS M Y",mktime(0,0,0,3,$i,2004));
      $n=date("w",mktime(0,0,0,3,$i,2004));
      echo $d,": day of week is $n<br />";
   }
   echo "</pre>";
?>


Outputs the details of March this year. Look at 28th March. It thinks it?s the 27th! Now I know this is the change to daylight saving but mktime says all should be well! However, if I change the hour to be 12 (right smack in the middle) it gets the week day right (0 and not 6) but it still thinks its Saturday.  I'm in the UK and the clocks changed on this day.


Mon 01st Mar 2004: day of week is 1
Tue 02nd Mar 2004: day of week is 2
Wed 03rd Mar 2004: day of week is 3
Thu 04th Mar 2004: day of week is 4
Fri 05th Mar 2004: day of week is 5
Sat 06th Mar 2004: day of week is 6
Sun 07th Mar 2004: day of week is 0
Mon 08th Mar 2004: day of week is 1
Tue 09th Mar 2004: day of week is 2
Wed 10th Mar 2004: day of week is 3
Thu 11th Mar 2004: day of week is 4
Fri 12th Mar 2004: day of week is 5
Sat 13th Mar 2004: day of week is 6
Sun 14th Mar 2004: day of week is 0
Mon 15th Mar 2004: day of week is 1
Tue 16th Mar 2004: day of week is 2
Wed 17th Mar 2004: day of week is 3
Thu 18th Mar 2004: day of week is 4
Fri 19th Mar 2004: day of week is 5
Sat 20th Mar 2004: day of week is 6
Sun 21st Mar 2004: day of week is 0
Mon 22nd Mar 2004: day of week is 1
Tue 23rd Mar 2004: day of week is 2
Wed 24th Mar 2004: day of week is 3
Thu 25th Mar 2004: day of week is 4
Fri 26th Mar 2004: day of week is 5
Sat 27th Mar 2004: day of week is 6
Sat 27th Mar 2004: day of week is 6
Mon 29th Mar 2004: day of week is 1
Tue 30th Mar 2004: day of week is 2
Wed 31st Mar 2004: day of week is 3



Reproduce code:
---------------
<?php
   $n=date("w",mktime(0,0,0,3,29,2004));
   echo "<pre>";
   for($i=1;$i<32;$i++)
   {
      $d=date("D dS M Y",mktime(0,0,0,3,$i,2004));
      $n=date("w",mktime(0,0,0,3,$i,2004));
      echo $d,": day of week is $n<br />";
   }
   echo "</pre>";
?>


Expected result:
----------------
the correct dates, refer to description

Actual result:
--------------
the wrong dates. refer to description

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-03 07:16 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 00:01:41 2024 UTC