Bug #80974 [PATCH]: Wrong diff between 2 dates in different timezones

From: Date: Thu, 22 Apr 2021 09:50:37 +0000
Subject: Bug #80974 [PATCH]: Wrong diff between 2 dates in different timezones
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233552@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80974&edit=1

 ID:                 80974
 Patch added by:     cmb@php.net
 Reported by:        kylekatarnls at gmail dot com
 Summary:            Wrong diff between 2 dates in different timezones
 Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 Operating System:   Ubuntu
 PHP Version:        master-Git-2021-04-21 (Git)
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2021-04-21 22:00:40] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80974&edit=1


Thread (8 messages)

« previous php.bugs (#233552) next »