[php-src] Issue #8153: DateTime->sub produces different value than on older versions
| From: | grzegorz-rozycki | Date: | Fri, 25 Feb 2022 15:49:13 +0000 |
| Subject: | [php-src] Issue #8153: DateTime->sub produces different value than on older versions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240033@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8153
Author: grzegorz-rozycki
### Description
The following code:
https://3v4l.org/1kqoo
```php
<?php
$today = new DateTime('today');
$delta = new DateInterval('PT0S');
$delta->f = 0.0001;
$expectedLower = (clone $today)
->setTimezone(new DateTimeZone('UTC'))
->sub($delta);
var_dump($expectedLower);
```
Resulted in this output:
```
object(DateTime)#3 (3) {
["date"]=>
string(26) "2022-02-24 23:00:00.999900"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
```
But I expected this output instead:
```
object(DateTime)#3 (3) {
["date"]=>
string(26) "2022-02-24 22:59:59.999900"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
```
### PHP Version
PHP 8.1.3
### Operating System
Docker image php:8.1.3-cli-buster