[php-src] Issue #9106: \DateInterval 1.5s added to DateTimeInterface is rounded down since PHP 8.1.0
| From: | norberttech | Date: | Fri, 22 Jul 2022 20:13:21 +0000 |
| Subject: | [php-src] Issue #9106: \DateInterval 1.5s added to DateTimeInterface is rounded down since PHP 8.1.0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241992@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9106
Author: norberttech
### Description
The following code:
```php
<?php
$start = new \DateTimeImmutable("2020-01-01 00:00:00 UTC");
$oneAndHalfSec = new \DateInterval("PT1S");
$oneAndHalfSec->f = 0.5;
$t1 = $start->add($oneAndHalfSec);
$t2 = $t1->add($oneAndHalfSec);
$t3 = $t2->add($oneAndHalfSec);
$t4 = $t3->add($oneAndHalfSec);
var_dump($start->getTimestamp());
var_dump($t1->getTimestamp());
var_dump($t2->getTimestamp());
var_dump($t3->getTimestamp());
var_dump($t4->getTimestamp());
```
Resulted in this output in PHP 8.1.0 - 8.1.8:
```
int(1577836800)
int(1577836801)
int(1577836802)
int(1577836803)
int(1577836804)
```
But I expected this output instead, like in PHP 7.4.0 - 7.4.30, 8.0.1 - 8.0.21:
```
int(1577836800)
int(1577836801)
int(1577836803)
int(1577836804)
int(1577836806)
```
### PHP Version
8.1.8
### Operating System
_No response_