You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DateTime::diff miscalculation is same time zone of different type #8730
Something appears amiss when DateTime::diff is used on two dates in the same time zone with different time zone types in DST
Possibly related to #81263
The following code:
Since php 8.1.0 diff compares time zone type equality, in some circumstances although type 1 (numeric time zone) or type 3 (literal time zone) may produce a date with daylight saving time setting. (it means that although type 3 time zone converted to numerical sequence of seconds is exactly the same as type 1 time zone, as php decides whether to consider daylight saving time or not).
It is difficult to document and too much information is confusing, certainly a good encoding is to use the same type timezone for the two date objects requested by diff.
This change https://bugs.php.net/bug.php?id=81458
$foo is big to $bar, inverter to $bar->diff($foo));
Activity
hormus commentedon Jun 12, 2022
Since php 8.1.0 diff compares time zone type equality, in some circumstances although type 1 (numeric time zone) or type 3 (literal time zone) may produce a date with daylight saving time setting. (it means that although type 3 time zone converted to numerical sequence of seconds is exactly the same as type 1 time zone, as php decides whether to consider daylight saving time or not).
https://wiki.php.net/rfc/datetime_and_daylight_saving_time
It is difficult to document and too much information is confusing, certainly a good encoding is to use the same type timezone for the two date objects requested by diff.
This change https://bugs.php.net/bug.php?id=81458
$foo is big to $bar, inverter to $bar->diff($foo));
Note* US/Eastern https://www.php.net/manual/en/timezones.others.php
before php 8.1 the comparison was for the date represented by the conversion to UTC
derickr commentedon Jun 17, 2022
Fixed in timelib: derickr/timelib#128, and the fix will make it into PHP once timelib gets merged again.
ToshY commentedon Jul 20, 2022
@derickr Could you give an estimation on when this (timelib fix) actually gets merged?
Fixed phpGH-8730: DateTime::diff miscalculation is same time zone of …
derickr commentedon Jul 21, 2022
Just now :-)
jabelli commentedon Jul 21, 2022
Create new for 8.2 or reopen this one? I just tested 8.2β1: