Bug #76032 [Opn->Csd]: DateTime->diff having issues with leap days for timezones ahead of UTC

From: Date: Tue, 06 Apr 2021 19:55:20 +0000
Subject: Bug #76032 [Opn->Csd]: DateTime->diff having issues with leap days for timezones ahead of UTC
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233261@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76032&edit=1 ID: 76032 Updated by: derick@php.net Reported by: simon at welsh-au dot com Summary: DateTime->diff having issues with leap days for timezones ahead of UTC -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: Linux PHP Version: 7.2.2 -Assigned To: +Assigned To: derick Block user comment: N Private report: N New Comment: The fix for this bug has been committed. If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test. Thank you for the report, and for helping us make PHP better. Fixed for PHP 8.1. Previous Comments: ------------------------------------------------------------------------ [2021-03-24 04:34:52] lominum at protonmail dot com This also happens for simple month calculations: A diff with 2021-03-01 to 2021-06-01 results in 3 months and 3 days https://3v4l.org/HqGMh Changing this to 2021-03-02 to 2021-06-02 results in a correct 3 months and 0 days https://3v4l.org/KlM3m ------------------------------------------------------------------------ [2018-02-28 22:40:54] simon at welsh-au dot com Description: ------------ When in a timezone that's ahead of UTC, DateTime->diff seems to have issues when the starting date falls on a leap day in UTC. In the test script, changing the dates from March 1 to March 2 has both var_dump calls showing 10. Test script: --------------- <?php date_default_timezone_set('UTC'); $d = new DateTime('2008-03-01'); $a = new DateTime('2018-03-01'); var_dump($d->diff($a)->y); date_default_timezone_set('Europe/Amsterdam'); $d = new DateTime('2008-03-01'); $a = new DateTime('2018-03-01'); var_dump($d->diff($a)->y); Expected result: ---------------- int(10) int(10) Actual result: -------------- int(10) int(9) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76032&edit=1

« previous php.bugs (#233261) next »