How to get month name by number

Advertisements

I have used this code in PHP to get month name by number its giving right answer in 01,02 upto 07 and saying wrong literal passes when I pass 08 and 09 for 11 and 12 as well giving right answer

$monthNum  = 09;
$monthName = date('F', mktime(0, 0, 0, $monthNum, 10));
echo $monthName

>Solution :

09 is invalid integer, you can’t have this. But if you want to keep it this way for some reason – use a string.
$monthNum = '09';

Leave a ReplyCancel reply