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: 2021-04-06 19:54 UTC
Votes:22
Avg. Score:4.8 ± 0.4
Reproduced:22 of 22 (100.0%)
Same Version:13 (59.1%)
Same OS:15 (68.2%)
From: heiglandreas@php.net Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.1.3 OS: Irrelelvant
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 - 2 = ?
Subscribe to this entry?

 
 [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

Pull Requests

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
 [2021-04-06 19:54 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 [2021-04-06 19:54 UTC] derick@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed for PHP 8.1.
 [2021-11-04 22:16 UTC] kylethielk at gmail dot com
Derick is there a plan to add support for this to other active version of PHP rather than just 8.x? 

PHP 7.4 is still in active development, it would be great to get this fix merged into 7.4 as well.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 14:01:27 2024 UTC