You can get just the textual month of a Unix time stamp with the F
date()
format character, and you can turn almost any format of date into a Unix time stamp with strtotime(), so pick any year and a day 1 to 28 (so it's present in all 12 months) and do:
$written_month = date("F", strtotime("2001-$number_month-1"));
// Example - Note: The year and day are immaterial:
// 'April' == date("F", strtotime("2001-4-1"));
Working example
The nice thing about using strtotime()
is that it is very flexible. So let's say you want an array of textual month names that starts one month from whenever the script is run;
<?php
for ($number = 1; $number < 13; ++$number) {
// strtotime() understands the format "+x months"
$array[] = date("F", strtotime("+$number months"));
}
?>
Working example
date
is good enough?