April 11, 2009

PHP Month Number to Month Name the Easy Way

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.

$monthNum = 5;
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
echo $monthName; //output: May


Looking for more?

Subscribe to my newsletter to get infrequent updates in your inbox. Or follow me on Twitter.