Reputation: 3878
I have a variable with a 2 digit month number. Is there a built in function that allows me to change it to the month name. I thought maybe the date()
function would work, but that requires a full timestamp.
Upvotes: 2
Views: 6791
Reputation: 3385
I use the following which is easier to code when needed many times
$month_names = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
echo $month_names[3]; //prints March
Useful if you have a header or config file that's included on all your pages
Upvotes: 1
Reputation: 77104
You can use mktime
with arbitrary parameters (exception of month) and then format using date
(this might buy you something as far as locales).
date('M', mktime(0, 0, 0, $month, 1, 2000));
Upvotes: 9
Reputation: 1398
Not to my knowledge.
You could use:
<?php
$monate = array(
1=>"Januar",
2=>"Februar",
3=>"März",
4=>"April",
5=>"Mai",
6=>"Juni",
7=>"Juli",
8=>"August",
9=>"September",
10=>"Oktober",
11=>"November",
12=>"Dezember");
?>
<?php
$monat = date("n");
??
Upvotes: -1