php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73138 strtotime miscalculates when exiting DST with relative time
Submitted: 2016-09-21 17:28 UTC Modified: 2016-09-21 20:35 UTC
From: z dot himdi at bita dot nl Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 5.6.26 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: z dot himdi at bita dot nl
New email:
PHP Version: OS:

 

 [2016-09-21 17:28 UTC] z dot himdi at bita dot nl
Description:
------------
strtotime does not calculate correctly when adding or subtracting time relatively while exiting DST.



Test script:
---------------
date_default_timezone_set("Europe/Amsterdam");

echo strtotime('+ 1 second', 1477789199);
// exiting DST in October, echoes 1477792800 in stead of 1477789200

echo strtotime('+ 1 second - 1 second', 1477789199);
// exiting and re-entering DST, echoes 1477792799 in stead of 1477789199

echo strtotime('- 1 second', 1459040400);
// exiting DST in March, echoes 1459043999 in stead of 1459040399


Expected result:
----------------
see the comments in the test script

Actual result:
--------------
one hour of unwanted difference

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-21 20:35 UTC] bwoebi@php.net
-Status: Open +Status: Assigned -Package: *General Issues +Package: Date/time related -Assigned To: +Assigned To: derick
 [2016-09-21 20:35 UTC] bwoebi@php.net
Related to bug #30532

This bug had been marked as fixed while not being fixed at all; the test (ext/date/tests/bug30532.phpt) is using the *actual* result instead of the *expected* result in the --EXPECT-- section, for some reason?

Most crucially:

echo date('r', strtotime('+ 0 second', 1477789199));

outputs:

Sun, 30 Oct 2016 02:59:59 +0100

which is ... exactly one hour later, while we, in fact, did not change anything to the time. (I very much hope "+ 0 second" is supposed to be a no-op!)
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC