Get month name from number in PHP


Please find below code

1.
$month=”January”;
$date = date_parse($month);
$month_number = $date[‘month’];

2.
switch ($m) {
case “January”:
case “Jan”:
$m = “01”;
break;
case “Febuary”:
case “Feb”:
$m = “02”;
break;
case “March”:
case “Mar”:
$m = “03”;
break;
case “April”:
case “Apr”:
$m = “04”;
break;
case “May”:
$m = “05”;
break;
case “June”:
case “Jun”:
$m = “06”;
break;
case “July”:
case “Jul”:
$m = “07”;
break;
case “August”:
case “Aug”:
$m = “08”;
break;
case “September”:
case “Sep”:
$m = “09”;
break;
case “October”:
case “Oct”:
$m = “10”;
break;
case “November”:
case “Nov”:
$m = “11”;
break;
case “December”:
case “Dec”:
$m = “12”;
break;
default:
$m = false;
break;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s