w3resource
php Programming Exercies

PHP Date Exercises : Convert the number to month name

PHP date: Exercise-26 with Solution

Write a PHP script to convert the number to month name.

Sample Solution:

PHP Code:

<?php
$month_num  = 9;
$dateObj   = DateTime::createFromFormat('!m', $month_num);
$month_name = $dateObj->format('F');
echo $month_name."\n";
?>

Sample Output:

September

Flowchart :

Flowchart: Convert the number to month name

PHP Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to get the current date in Italian.
Next: Write a PHP script to get the number of days of the current month.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming