
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
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
Advertisements