[英]How do I convert numeric month number to name of month using PHP
I have a variable with a 2 digit month number. 我有一个带有2位数月份数的变量。 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. 我想也许date()
函数可以工作,但这需要一个完整的时间戳。
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 如果您的所有页面都包含标题或配置文件,则非常有用
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");
??
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.