문제

I have month in a form

I'd like a php formula that do this

if month = 6 -> $month1='June' if month = 7 -> $month1='July' if month = 8 -> $month1='August' if month = 9 -> $month1='Septmber'
도움이 되었습니까?

해결책 2

Should work:

$month = 5;
$monthName = date("F", mktime(0, 0, 0, $month, 10));
echo $monthName;

다른 팁

Welcome to PHP :)

$month_names = array (
    "jan", "feb", "mar", "apr", "may", "jun",
    "jul", "aug", "sep", "oct", "nov", "dec");

$name = $month_name[$month-1];

Why not use the datetime object:

$month = 3;
$monthName = DateTime::createFromFormat('m', $month)->format('F');
echo $monthName;
function getName($monthNumber){
   return date("F", strtotime("2014-".$monthNumber."-1 12:00:00"));
}
$month = 8 ; // <-- or any number you want
echo getName($month);

Output : August

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top