tisuchi
December 2017
M T W T F S S
« Nov    
 123
45678910
11121314151617
18192021222324
25262728293031

Categories


How to convert number to month name in PHP

tisuchitisuchi

Here is the code that how can you convert number to month name in PHP. Think of it, you have a month number 01, 02, … that is equivalent to January, February, …

$monthNum  = 3;
$dateObj   = DateTime::createFromFormat('!m', $monthNum);
$monthName = $dateObj->format('F'); // March

Alternative way, you can try this-

$monthNum  = 3;
$monthName = date('F', mktime(0, 0, 0, $monthNum, 10)); // March

Enjoy.

<p>I speak PHP, Laravel, MySql, JavaScript, VueJS, Python, Bengali and English. I am originated from Bangladesh, currently working in Malaysia. My day time job is to develop web apps for EDV Standard, and night time, I solve coding issues for communities.</p>

Comments 0
There are currently no comments.