[php-src] Issue #9699: `DateTimeImmutable::diff` differences on in 8.1.10 onwards
| From: | bendavies | Date: | Mon, 10 Oct 2022 09:03:26 +0000 |
| Subject: | [php-src] Issue #9699: `DateTimeImmutable::diff` differences on in 8.1.10 onwards | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242557@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9699
Author: bendavies
### Description
The following code:
```php
<?php
$date = new DateTimeImmutable('2022-10-09 02:41:54.515330', new
DateTimeZone('America/Los_Angeles'));
$now = new DateTimeImmutable('2022-10-10 08:41:54.534620', new
DateTimeZone('UTC'));
var_dump($date->diff($now));
var_dump($date->diff($now));
```
Resulted in this output:
```
object(DateInterval)#3 (16) {
["y"]=>
int(-1)
["m"]=>
int(11)
["d"]=>
int(30)
["h"]=>
int(0)
["i"]=>
int(59)
["s"]=>
int(59)
["f"]=>
float(0.98071)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
```
But I expected this output instead:
```
object(DateInterval)#3 (16) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(23)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0.01929)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
```
https://3v4l.org/Jam7q
### PHP Version
8.1.10
### Operating System
_No response_