Should work:
$month = 5;
$monthName = date("F", mktime(0, 0, 0, $month, 10));
echo $monthName;
Question
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'
Solution 2
Should work:
$month = 5;
$monthName = date("F", mktime(0, 0, 0, $month, 10));
echo $monthName;
OTHER TIPS
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);