

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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...\n"; echo "Date = $date"; $month_name = date("F", mktime(0, 0, 0, 11, 10)); echo "\nMonth = ".$month_name."\n"; echo "\nDisplaying updated date...\n"; 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...\n"; echo "Date = $date"; $month_name = date("F", mktime(0, 0, 0, 11, 10)); echo "\nMonth = ".$month_name."\n"; echo "\nDisplaying updated date...\n"; echo date('Y-m-d', strtotime($date. ' + 20 days')); $val = DateTime::createFromFormat('!m', 12); $month_name2 = $val->format('F'); echo "\nMonth = ".$month_name2."\n"; ?>
Output
This will produce the following output −
Displaying date... Date = 2019-11-11 Month = November Displaying updated date... 2019-12-01 Month = December
- Related Questions & Answers
- Convert datetime to get month name in MySQL?
- Get Month Name from Month number in MySQL?
- Convert DATE timestamp to return only the month name in MySQL
- Convert DATE timestamp to return the 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 a string into number in PHP?
- MySQL query to convert a string into a month (Number)?
- Output only the name of the month instead of the month number in MySQL
- How to validate domain name in PHP?
- MySQL query to convert timestamp to month?
- How to get current function name in PHP?
- How to convert array to string PHP?
- How to convert string to boolean in PHP?
- How to convert year, month, and day of the month into a complete date in R?
Advertisements