[php-src] Issue #8475: DateTimeImmutable->diff fails to understand months in Europe/Paris timezone
| From: | hormus | Date: | Tue, 03 May 2022 11:55:13 +0000 |
| Subject: | [php-src] Issue #8475: DateTimeImmutable->diff fails to understand months in Europe/Paris timezone | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241402@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8475
Comment Author: hormus
DateTime::__construct or DateTimeImmutable::__construct accepts an optional signed integer string if
preceded by the @ character. Unix time Stamp through format('U') in php code can be
negative for operating systems limited to 32 bits This premise is about how DateTime works, while
calculating the difference between two dates is not always reversible. Currently the DateTime class
keeps the date object, timezone used is the type while diff from php 8.1.0 if they don't have
the same timezone it converts it to UTC. In this scenario it is always wrong as users might interact
with different transition periods or even with different timezones than the initial one. A range
between two dates should be used for the same transition period and timezone on both sides and for
the same version of php. @cmb69 Documentation for DateTime::diff or DateTimeImmutable::diff is
missing, accuracy may be inaccurate. Before php 8.1.0 instead of calculating the actual time the
constructor erroneously calculated the conversion to UTC which means addition or subtraction offset
of the timezone.