[php-src] Issue #11237: strtotime changed behavior between PHP 8.0.x to 8.2.x

From: Date: Fri, 12 May 2023 23:13:15 +0000
Subject: [php-src] Issue #11237: strtotime changed behavior between PHP 8.0.x to 8.2.x
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244438@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11237 Author: ppazos ### Description This is an online comparison: https://onlinephp.io?s=s7EvyCjg5eLlUikuSSwqycxLj8_NzyvJULBV0DUysQbJpCZn5CuopGUWFZdA5OLBSuNTEktSgcrSc0EMDfVI3VxdA0MFAwMrMFLXUSguKSrJL8nMTdVQKsnILFYAay5WQLcJKqxtCGUpaWoq6AV4BMS7-vvQxAHaA-4CYNAOgLcJ2goA&v=8.2.6%2C8.0.13 The following code: ```php <?php $starting_month = -24; echo $first_month_start_date = gmdate('Y-m-01 00:00:00', strtotime("this months $starting_month months +1 months")) .PHP_EOL; echo $first_month_start_date = gmdate('Y-m-01 00:00:00', strtotime("this months +$starting_month months +1 months")) .PHP_EOL; echo $first_month_start_date = gmdate('Y-m-01 00:00:00', strtotime("this months -24 months +1 months")) .PHP_EOL; echo $first_month_start_date = gmdate('Y-m-01 00:00:00', strtotime("this months +-24 months +1 months")) .PHP_EOL; ``` Resulted in this output: ``` For 8.2.6: 2021-06-01 00:00:00 2025-06-01 00:00:00 2021-06-01 00:00:00 2025-06-01 00:00:00 For 8.0.13: 2021-06-01 00:00:00 2021-06-01 00:00:00 2021-06-01 00:00:00 2021-06-01 00:00:00 ``` But I expected this output instead: ``` 2021-06-01 00:00:00 2021-06-01 00:00:00 2021-06-01 00:00:00 2021-06-01 00:00:00 ``` NOTES: 1. Having a +- sign makes the expression ignore the - sign. 2. Having no sign at all seems to work as it has a + sign: "this months 24 +1 months" => 2025-06-01 00:00:00 ### PHP Version PHP 8.2.6 ### Operating System Linux

« previous php.bugs (#244438) next »