Bug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
| From: | ayanozturk at gmail dot com | Date: | Thu, 03 Nov 2022 11:58:23 +0000 |
| Subject: | Bug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-242743@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81458&edit=1
ID: 81458
Comment by: ayanozturk at gmail dot com
Reported by: kylekatarnls at gmail dot com
Summary: Regression in PHP 8.1: Incorrect difference after
timezone change
Status: Closed
Type: Bug
Package: Date/time related
PHP Version: 8.1Git-2021-09-18 (Git)
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
Hi, not sure if this is related.
DateTime diff for 'year' in different timezones returns -1 after PHP 8.1.10 instead of 0.
Is this a known bug?
$utc = new DateTimeZone('UTC');
$london = new DateTimeZone('Europe/London');
$test1 = new \DateTime('2018-01-31', $utc);
$test2 = new \DateTime('2018-04-08', $london);
$dateDiff = $test1->diff($test2);
echo $dateDiff->y;
Previous Comments:
------------------------------------------------------------------------
[2021-11-18 14:04:28] derick@php.net
Should be fixed now Kyle, it had nothing to do with a regression, but with a missing "="
-> https://github.com/derickr/timelib/commit/b8885ede02dea903a42b82d1fcb99e708b76e384
------------------------------------------------------------------------
[2021-11-17 10:36:08] kylekatarnls at gmail dot com
Hello derick,
FYI I now get this returning me days = 0 using master branch, while if I properly understood your
specs it should be 1:
```
date_default_timezone_set('UTC');
$a = new DateTime('2018-12-01 00:00');
$b = new DateTime('2018-12-02 00:01');
var_dump($a->diff($b));
```
So it sounds now there is a regression when both are in UTC.
------------------------------------------------------------------------
[2021-11-08 09:40:54] git@php.net
Automatic comment on behalf of derickr
Revision: https://github.com/php/php-src/commit/904933e9185664148ce5459f93726f54f572b6c3
Log: Fixed bug #81458: Regression: Incorrect difference after timezone change
------------------------------------------------------------------------
[2021-11-05 12:46:17] derick@php.net
FWIW, I started working on this, but it's a tad more work than I expected.
------------------------------------------------------------------------
[2021-11-02 21:00:33] kylekatarnls at gmail dot com
Exactly absolute(floor(($one->unixTime - $two->unixTime) / 86400)) is a good fallback to
calendar diff when ambiguous. Thank you.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=81458
--
Edit this bug report at https://bugs.php.net/bug.php?id=81458&edit=1