我有个月的表格
我想要一个执行此操作的php公式
if month = 6 -> $month1='June' if month = 7 -> $month1='July' if month = 8 -> $month1='August' if month = 9 -> $month1='Septmber'
答案 0 :(得分:2)
欢迎使用PHP:)
$month_names = array (
"jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec");
$name = $month_name[$month-1];
答案 1 :(得分:0)
应该工作:
$month = 5;
$monthName = date("F", mktime(0, 0, 0, $month, 10));
echo $monthName;
答案 2 :(得分:0)
为什么不使用datetime对象:
$month = 3;
$monthName = DateTime::createFromFormat('m', $month)->format('F');
echo $monthName;
答案 3 :(得分:0)
function getName($monthNumber){
return date("F", strtotime("2014-".$monthNumber."-1 12:00:00"));
}
$month = 8 ; // <-- or any number you want
echo getName($month);