[php-src] Issue #9386: 8.1.7 introduced regression in parsing relative date strings with "after"

From: Date: Sat, 20 Aug 2022 00:19:31 +0000
Subject: [php-src] Issue #9386: 8.1.7 introduced regression in parsing relative date strings with "after"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242265@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9386 Author: cabbey ### Description The following code: ```php new DateTimeImmutable("3 Mondays after 2022-01-01 00:00:00"); ``` Resulted in this output: ``` Fatal error: Uncaught Exception: Failed to parse time string (3 Mondays after 2022-01-01 00:00:00) at position 10 (a): The timezone could not be found in the database in /in/YO1fV:3 Stack trace: #0 /in/YO1fV(3): DateTimeImmutable->__construct('3 Mondays after...') #1 {main} thrown in /in/YO1fV on line 3 ``` But I expected a valid DateTimeImmutable object. See https://3v4l.org/YO1fV for a small test case using it plus a format output. Workaround (at least for the cases we care about) is to rephrase the string to be "third Monday of January 2022". This will only work for cases where you were doing an after with a date that is the first of the month. If you were trying to do something like "12th Wednesday after 2022-06-14" that would not work and you would need to do a pretty substantial refactor to find a Wednesday after then date then move forward. Also note that the error message talks about trying to look up a timezone... if you add a timezone offset value to the time stamp in the string, you get a DIFFERENT error message on php >= 8.1.7 than you did on php <= 8.1.6; these messages also seem to indicate it's related to the timezone changes that were made in 8.1.7. ### PHP Version PHP 8.1.7 ### Operating System _No response_

« previous php.bugs (#242265) next »