I'm making a function to check the month is valid or not. For eg.
checkMonth("Feb") => true
checkMonth("Mar") => true
checkMonth(02) => true
checkMonth(2) => true
But
checkMonth("X") => false
checkMonth("XYZ") => false
There is no issue in the numeric form 2 or 02. But if I'm passing argument like "X" or "XYZ" its not working and returns true.
Im trying
echo date('n', strtotime("XYZ"));
which is returning true because the value of date('n', strtotime("XYZ")) is 3 which is a valid month.
I also tried
$mon=date_format(date_create("XYZ"),"n");
But it has the same affect.