How To Get Month Name from Date in PHP Tutorial

Share this Article
Reading Time: 3 minutes
394 Views

Inside this article we will see the concept to get month name from date in php. There are several options in php which helps to get the month name name. Article contains classified information about PHP tutorial to get month name.

If you are looking for an article which helps you to get month name from date then you are at right place to learn in a very easy way.

Learn More –

Let’s get started.


Example 1: Get Full Month Name from Date

Create a file index.php at your localhost directory.

Open index.php and write this complete code into it.

<?php

$date = "2021-10-02";

$newDate = date('F', strtotime($date));

echo $newDate;

// Output: October

Output

October

Example 2: Get Full Month Name from Current Date

Create a file index.php at your localhost directory.

Open index.php and write this complete code into it.

<?php

$newDate = date('F');

echo $newDate;

// Output: November

Output

November

Example 3: Get Short Month Name from Date

Create a file index.php at your localhost directory.

Open index.php and write this complete code into it.

<?php

$date = "2021-08-02";

$newDate = date('M', strtotime($date));

echo $newDate;

// Output: Aug

Output

Aug

Example 4: Get Short Month Name from Current Date

Create a file index.php at your localhost directory.

Open index.php and write this complete code into it.

<?php

$newDate = date('M');

echo $newDate;

// Output: Nov

Output

Nov

Example 5: Get Month Name from Number

Create a file index.php at your localhost directory.

Open index.php and write this complete code into it.

<?php

$monthNumber  = 8;
$monthName = date('F', mktime(0, 0, 0, $monthNumber, 10));

echo $monthName;

// Output: August

Output

August

We hope this article helped you to learn How to Get Month Name from Date in PHP Tutorial in a very detailed way.

Buy Me a Coffee

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Learn Web Development Courses @ $4 only.
Web Development Courses @ $4