[php-src] Issue #8012: DateTime last day of February fall down to January or March

From: Date: Mon, 31 Jan 2022 09:06:06 +0000
Subject: [php-src] Issue #8012: DateTime last day of February fall down to January or March
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239367@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8012 Author: ybenhssaien ### Description The following code (tested 31/01/2022): ```php <?php var_dump(Datetime::createFromFormat('Ym', '202102')->modify('last day')); var_dump(Datetime::createFromFormat('Ym', '202102')->modify('last day of this month')); var_dump(Datetime::createFromFormat('!Ym', '202102')->modify('last day')); var_dump(Datetime::createFromFormat('!Ym', '202102')->modify('last day of this month')); ``` Resulted in this output: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "2021-03-02 09:59:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2021-03-31 09:59:43.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2021-01-31 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2021-02-28 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ``` But I expected this output instead (for all those cases): ``` object(DateTime)#1 (3) { ["date"]=> string(26) "2021-02-28 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ``` ### PHP Version All versions 7.4.0 - 7.4.27, 8.0.1 - 8.0.15, 8.1.0 - 8.1.2 ### Operating System Ubuntu 20

« previous php.bugs (#239367) next »