Home > Net >  PHP DateTime::createFromFormat return wrong date
PHP DateTime::createFromFormat return wrong date

Time:09-28

I've got a date like : $date = DateTime::createFromFormat('D d/m', 'Mon 05/02'); but instead of 05 february the datetime returned is DateTime Object ( [date] => 2021-02-08 10:02:10.000000 [timezone_type] => 3 [timezone] => Europe/Brussels )

Answer Corrected with the Y input and got the right result, php was using 2021 when i was constructing 2022 year

CodePudding user response:

Because in 2021, February 5 is Friday, and February 8 is Monday.

  • Related