php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74274 Handling DST transitions correctly
Submitted: 2017-03-19 10:09 UTC Modified: 2017-03-19 12:10 UTC
Votes:14
Avg. Score:4.6 ± 0.5
Reproduced:14 of 14 (100.0%)
Same Version:11 (78.6%)
Same OS:11 (78.6%)
From: heiglandreas@php.net Assigned:
Status: Open Package: Date/time related
PHP Version: 7.1.3 OS: Irrelelvant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-03-19 10:09 UTC] heiglandreas@php.net
Description:
------------
A lot of issues have been tracked regarding DST-Transitions. There also has been an RFC in 2011 (https://wiki.php.net/rfc/datetime_and_daylight_saving_time) which seems to be not implemented yet. 

This is supposed to be a collection of all the issues that have been raised up to now that all revolve around the same thing:

DateTime doesn't handle the transition from Daylight Saving Time back to Standard Time correctly. 

https://bugs.php.net/bug.php?id=51051
https://bugs.php.net/bug.php?id=61530
https://bugs.php.net/bug.php?id=62185


This is closely related to an often claimed feature request to evaluate the Timezone-Parameter when a Timezone-identifier is given in the datetime-string. That would allow DateTime to realize whether the given time is DaylightSavingTime or Standard-Time and be a much less error prone way than using 'DT' and 'ST' as described in the RFC. Related to this are:

https://bugs.php.net/bug.php?id=61022



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-06 03:08 UTC] Jeremy at jcarnus dot fr
Hi
Is there a way to know when this will be solved ? 
Thanks
 [2018-11-07 21:14 UTC] oliverpool at hotmail dot fr
I found a simple test case where the DateInterval returned from `diff` looks quite strange (a complete day is missing):

$tz = new DateTimeZone("Europe/Paris");
$startDate = new \DateTime('2018-10-28 00:00:00', $tz);
$endDateBuggy = new \DateTime('2018-10-29 23:00:00', $tz);
$endDateCorrect = new \DateTime('2018-10-29 22:59:59', $tz);

// Buggy output
print_r($startDate->diff($endDateBuggy));
/*
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 2
    [h] => -1
    [i] => 0
    [s] => 0
    [f] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 1 ///////////////////// This is lower than [d]! This should be 2
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)
*/


// Correct Output
print_r($startDate->diff($endDateCorrect));
/*
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 1
    [h] => 22
    [i] => 59
    [s] => 59
    [f] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 1
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)
*/


This impacts Carbon: https://github.com/briannesbitt/Carbon/issues/1496
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 18:01:26 2019 UTC