php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71383 strtotime(), date() skip hour in "2016-03-13 02:00:00" & "2016-03-13 03:00:00"
Submitted: 2016-01-15 22:36 UTC Modified: 2016-01-16 00:59 UTC
From: traci at jbsystemsllc dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.5.31 OS: OS x 10.8.5
Private report: No CVE-ID: None
 [2016-01-15 22:36 UTC] traci at jbsystemsllc dot com
Description:
------------
strtotime is returning the same value for "2016-03-13 02:00:00" and "2016-03-13 03:00:00". The resulting date() is incorrect when the hour is 2. During this hour the 3600 seconds that would be added to strtotime is skipped.

Test script:
---------------
for($i=0;$i<10;$i++){
  echo strtotime('2016-03-13 0'.$i.':00:00');
  echo '<br>';
  echo date('g:i A',strtotime('2016-03-13 0'.$i.':00:00'));
  echo '<br>';
}

Expected result:
----------------
1457848800
12:00 AM
1457852400
1:00 AM
1457856000
2:00 AM
1457859600
3:00 AM
1457863200
4:00 AM
1457866800
5:00 AM
1457870400
6:00 AM
1457874000
7:00 AM
1457877600
8:00 AM
1457881200
9:00 AM

Actual result:
--------------
1457848800
12:00 AM
1457852400
1:00 AM
1457856000 (correct strtotime value)
3:00 AM    (incorrect hour value from date)
1457856000 (strtotime skips 3600 seconds)
3:00 AM    
1457859600
4:00 AM
1457863200
5:00 AM
1457866800
6:00 AM
1457870400
7:00 AM
1457874000
8:00 AM
1457877600
9:00 AM

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-16 00:59 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2016-01-16 00:59 UTC] rasmus@php.net
That would be the daylight savings time switch. That is exactly how it works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 01:01:33 2024 UTC