aausterm
aausterm

Reputation: 147

PHP DateTime November Bug

I am having an issue where using DateTime::createFromFormat() is skipping November. The code I am executing is:

$dateTime = DateTime::createFromFormat('m Y', "11 2016");
return $dateTime->format('F Y');

This keeps returning December 2016. If I change the 11 to 10 it returns October 2016 and if I change it to 12 it returns December 2016. Why is it skipping November?

Upvotes: 0

Views: 92

Answers (1)

John Conde
John Conde

Reputation: 219874

It's using the current day of the month because you did not specify a day. There is no 31st of November so it uses the next logical day: December 1st.

Upvotes: 2

Related Questions