php-src
php-src copied to clipboard
DateTime modify function backward compatibility break on 8.2
Description
The following code:
<?php
$modifiedDate = (new DateTime('2023-01-17'))->modify(sprintf('+%s days', $days))->format('Y-m-d');
Resulted in this output:
For values of $days lower than 0 results are incorrect (according to version 8.1). If value is -1 we get
'2023-01-18'
But I expected this output instead:
'2023-01-16'
PHP Version
8.2
Operating System
Ubuntu 20.04
@pkusmierczyk I think that would be the same as here https://github.com/php/php-src/issues/9950, so it is documented BC (via https://github.com/php/doc-en/commit/ef51b1ce007349e7ff415ec5c707f1b5a73aba27) "number symbols in relative formats no longer accept multiple signs, e.g. +-2"
Yes, its the same, I couldn't find anything similar before so I have created a new issue