I need to convert 'Nov22' into a date object that is in the month of November. I am trying the following - but it only works with months with 31 days:
$novDateString = 'Nov22';
$decDateString = 'Dec22';
$novDate = DateTime::createFromFormat('My', $novDateString);
$decDate = DateTime::createFromFormat('My', $decDateString);
echo $novDate->format('m');
echo $decDate->format('m');
// output
12
12
As you can see, both Nov22 and Dec22 go to December. In fact, all months with less than 31 days go map to the month ahead of it. Is this a known issue or is there an easy way to solve?
jMyDateTime::createFromFormat('U', strtotime($novDateString))parse this as2023-11-22(and2023-12-22for$decDateString), so it thinks22is the day, not the year.