Deprecated: stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/webodisha/public_html/includes/functions/common.php on line 116

Deprecated: stripslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/webodisha/public_html/includes/functions/common.php on line 116
Convert Month Number to Month Name in PHP | WebOdisha.in

Convert Month Number to Month Name in PHP

There is a very simple method to convert a month number to a month name in PHP, without using the lenghty switch statement.

<?php
$month_number = 11;
$month_name = date("F", mktime(0, 0, 0, $month_number, 10));
echo $month_name; //output: October
$month_name = date("M", mktime(0, 0, 0, $month_number, 10));
echo $month_name; //output: Oct
$month_total_days = date("t", mktime(0, 0, 0, $month_number, 10));
echo $month_total_days; //output: 31
?>
webodisha.in