[php-src] Issue #10228: Invalid DateTime::modify with negative offset in PHP 8.2

From: Date: Thu, 05 Jan 2023 11:17:50 +0000
Subject: [php-src] Issue #10228: Invalid DateTime::modify with negative offset in PHP 8.2
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243344@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10228
Author: pavol-tuka

### Description

DateTime::modify or DateTimeImmutable::modify in PHP 8.2 returns invalid
result with negative offset.

```php
$now = new DateTimeImmutable(); // 2023-01-05

$offset = -2;
var_dump($now->modify('+' . $offset . '
days')->format('Y-m-d'));

$offset = 2;
var_dump($now->modify('+' . $offset . '
days')->format('Y-m-d'));
```

PHP 8.1.14 output:
```
string(10) "2023-01-03"
string(10) "2023-01-07"
```

PHP 8.2.1 output:
```
string(10) "2023-01-07"
string(10) "2023-01-07"
```

### PHP Version

PHP 8.2.1

### Operating System

Linux Mint 21.1


Thread (1 message)

  • pavol-tuka
« previous php.bugs (#243344) next »