How to convert number to month name in PHP?
Hi Guys,
In this example,I will learn you how to convert number to month name in php.you can easy nad simply convert number to month name in php.
The DateTime::createFromFormat() function is an inbuilt function in php which is used to parses a time string according to a specified format. This function accepts three parameters and returns new DateTime in success or false on failure.
Example:
<?php
$monthNum = 5;
$dateObj = DateTime::createFromFormat('!m', $monthNum);
$monthName = $dateObj->format('F');
echo $monthName;
?>
Output:
May
It will help you...
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example