Skip to content

Instantly share code, notes, and snippets.

@albertski
Last active August 3, 2016 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albertski/b4069a09b29010b11fefa7cec5f31e7b to your computer and use it in GitHub Desktop.
Save albertski/b4069a09b29010b11fefa7cec5f31e7b to your computer and use it in GitHub Desktop.
Get Month Name From Number
<?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