Undocumented behaviour difference between php7.4 and php8.2
atm-florianm opened this issue · 0 comments
atm-florianm commented
From manual page: https://php.net/function.strtotime
[edit] My bad, I found this page where the change is, in fact, documented. However, the page is not easy to find. I think there should be a warning when an incorrect number format is used.
I noticed the following difference in output for the same code between php7.4 and php8.2:
echo date('Y', strtotime('+-1 year', time()));
// php7.4: 2023
// php8.2: 2025
I didn't find this difference documented anywhere.
Maybe +-
should be discouraged with a warning ?
Versions used for this comparison:
PHP 7.4.3-4ubuntu2.19 (cli) (built: Jun 27 2023 15:49:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3-4ubuntu2.19, Copyright (c), by Zend Technologies
PHP 8.2.15 (cli) (built: Jan 20 2024 14:16:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.15, Copyright (c) Zend Technologies
with Zend OPcache v8.2.15, Copyright (c), by Zend Technologies
with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans