Friday, August 3, 2012

Give Month number Get month name in PHP


Here’s a quickie for you. 
Ever wanted to convert a month number to a month name in PHP but hated having to do a huge switch statement? Well here is your answer.

<?php
$monthNum = 5;
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
echo $monthName; //output: May
?>
Enjoy.

No comments:

Post a Comment