php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80974 Wrong diff between 2 dates in different timezones
Submitted: 2021-04-21 22:00 UTC Modified: 2021-04-21 22:03 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kylekatarnls at gmail dot com Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: master-Git-2021-04-21 (Git) OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2021-04-21 22:00 UTC] kylekatarnls at gmail dot com
Description:
------------
In PHP < 8.1, comparing 2 date-times from different timezones would consider the real moment they represent to return the diff, which is completly relevant. But it's no longer true (sounds like introduced by 091c0920b9db057a54dc43ece6e864bce6818d5e).

Test script:
---------------
$dtToronto = new DateTime('2012-01-01 00:00:00.000000 America/Toronto');
$dtVancouver = new DateTime('2012-01-01 00:00:00.000000 America/Vancouver');

echo $dtVancouver->diff($dtToronto)->format('%h');

Expected result:
----------------
3

Actual result:
--------------
0

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-21 22:03 UTC] derick@php.net
-Assigned To: +Assigned To: derick
 [2021-04-22 09:50 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #80974: Wrong diff between 2 dates in different timezones
On GitHub:  https://github.com/php/php-src/pull/6896
Patch:      https://github.com/php/php-src/pull/6896.patch
 [2021-04-26 08:22 UTC] corey dot taylor dot fl at gmail dot com
I assume this is related since it was closed with the large patch from derick.

https://bugs.php.net/bug.php?id=79452
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 12 16:01:23 2021 UTC