
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to convert number to month name in PHP?
To convert number to month name in PHP, the code is as follows−
Example
<?php $date = "2019-11-11"; echo "Displaying date...
"; echo "Date = $date"; $month_name = date("F", mktime(0, 0, 0, 11, 10)); echo "
Month = ".$month_name."
"; echo "
Displaying updated date...
"; echo date('Y-m-d', strtotime($date. ' + 20 days')); ?>
Output
This will produce the following output−
Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01
Example
Let us now see another example −
<?php $date = "2019-11-11"; echo "Displaying date...
"; echo "Date = $date"; $month_name = date("F", mktime(0, 0, 0, 11, 10)); echo "
Month = ".$month_name."
"; echo "
Displaying updated date...
"; echo date('Y-m-d', strtotime($date. ' + 20 days')); $val = DateTime::createFromFormat('!m', 12); $month_name2 = $val->format('F'); echo "
Month = ".$month_name2."
"; ?>
Output
This will produce the following output −
Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01 Month = December
- Related Articles
- How to Convert Month Name to Number in Excel?
- Convert datetime to get month name in MySQL?
- Get Month Name from Month number in MySQL?
- Convert DATE timestamp to return the month number
- How to convert a string into number in PHP?
- Convert DATE timestamp to return only the month name in MySQL
- MySQL query to convert a string into a month (Number)?
- Getting month name instead of numeric month number in report in SAP
- Display month by name and number in Java
- How to convert string to boolean in PHP?
- MySQL query to convert timestamp to month?
- How to Convert Numbers to Year/Month/Day or Date in Excel?
- How to convert array to string PHP?
- How to convert year, month, and day of the month into a complete date in R?
- How to validate domain name in PHP?

Advertisements