Ask Question

Menu


How to convert string number into month name in PHP


<!DOCTYPE html>
<html>
<body>
<?php
$monthNum = 1;//Here 1 is the month number
$dateObj = DateTime::createFromFormat('!m', $monthNum);//Convert the number into month name
$monthName = $dateObj->format('F');
echo $monthName;
?>
</body>
</html>

Output:

January



Buy Template