Bug #52480 [Com]: Incorrect difference using DateInterval

From: Date: Sun, 25 Jul 2021 22:35:55 +0000
Subject: Bug #52480 [Com]: Incorrect difference using DateInterval
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235340@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52480&edit=1

 ID:                 52480
 Comment by:         antonino dot spampinato86 at gmail dot com
 Reported by:        alex dot joyce at staff dot comcen dot com dot au
 Summary:            Incorrect difference using DateInterval
 Status:             Closed
 Type:               Bug
 Package:            Date/time related
 Operating System:   irrelevant
 PHP Version:        7.1
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

Excuse me derick can you check, in UTC it's five months from 2010-02-28 13:00:00 to 2010-07-28
13:00:00. Five months in Australia/Sidney time zone from 2010-02-28 13:00:00 to 2010-07-28 12:00:00.
Not 4 months and 28 data.

Test script: https://3v4l.org/5KhLZ


Previous Comments:
------------------------------------------------------------------------
[2021-04-06 19:51:35] derick@php.net

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.

------------------------------------------------------------------------
[2021-03-20 21:18:39] dolgopolsky dot a at gmail dot com

Still happens for March 1-29 on PHP 7.4

------------------------------------------------------------------------
[2020-07-24 09:33:40] cmb@php.net

Related To: Bug #77969

------------------------------------------------------------------------
[2019-02-06 09:02:05] techouse at gmail dot com

I found something weird using timezones yesterday and reported it here https://bugs.php.net/bug.php?id=77571

Basically the DateInterval reports a wrong interval whenever a timezone between UTC+01:00 and
UTC+12:00 is applied. I wrote a bunch of tests with all kinds of timezones here https://github.com/techouse/php-date-interval-timezone-bug

------------------------------------------------------------------------
[2019-01-28 12:03:55] cz dot paranoiq at gmail dot com

another funny behavior of diff():

```
$start = new DateTime('1922-03-26 00:00:00');
$end = new DateTime('2000-01-02 00:00:00');
echo $end->diff($start, true)->format('%Y years, %m months, %d days, %h hours, %i
minutes, %s seconds');
```

returns some minutes and seconds, although both times are exact midnight. starts to be broken on
this start date or this interval length. breaks with another start time since PHP 7.3.2RC (somewhere
in 1892)

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


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=52480


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


Thread (28 messages)

« previous php.bugs (#235340) next »