Last active
August 3, 2016 20:48
-
-
Save albertski/b4069a09b29010b11fefa7cec5f31e7b to your computer and use it in GitHub Desktop.
Get Month Name From Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get month name from integer. | |
* | |
* @param integer $month_number Month number. | |
* | |
* @return string Month name. | |
*/ | |
function get_month_name($month_number) { | |
// Remove Leading 0. | |
$month_number = ltrim($month_number, '0'); | |
$months = array( | |
1 => 'January', | |
2 => 'February', | |
3 => 'March', | |
4 => 'April', | |
5 => 'May', | |
6 => 'June', | |
7 => 'July', | |
8 => 'August', | |
9 => 'September', | |
10 => 'October', | |
11 => 'November', | |
12 => 'December', | |
); | |
if (isset($months[$month_number])) { | |
return $months[$month_number]; | |
} | |
else { | |
return FALSE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment