[php-src] Issue #9636: Invalid month number for February in DateTime::format

From: Date: Thu, 29 Sep 2022 09:02:06 +0000
Subject: [php-src] Issue #9636: Invalid month number for February in DateTime::format
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242489@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9636 Author: jakubciszak ### Description The following code: ```php <?php $dateTime = DateTime::createFromFormat('m', '02'); print $dateTime->format('m') . PHP_EOL; $dateTime = DateTime::createFromFormat('Y-m', '2022-02'); print $dateTime->format('Y-m') . PHP_EOL; ``` Resulted in this output: ``` 03 2022-03 ``` But I expected this output instead: ``` 02 2022-02 ``` There is a problem with output of format function for february. The problem doeas not exists when we use day in date. Eg ```php <?php $dateTime = DataTime::format('m-d', '02-12'); print $dateTime->format('m-d'); ``` Resulted in this output: ``` 02-12 ``` ### PHP Version PHP 8.1.11, 8.0.24, 7.4.32, 7.2.34: ### Operating System Ubuntu 20.04, Ubuntu 22.04

« previous php.bugs (#242489) next »