Simple way to get current month name

Simple way to get current month name

$mons = array(1 => "Jan", 
2 => "Feb",
3 => "Mar", 
4 => "Apr", 
5 => "May", 
6 => "Jun", 
7 => "Jul", 
8 => "Aug", 
9 => "Sep", 
10 => "Oct", 
11 => "Nov", 
12 => "Dec");

$date = getdate();
$month = $date['mon']; 
$month_name = $mons[$month];

echo $month_name; 

or

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

echo $monthName;

0 comments: