how to get month from date in php – How to Get Month Name from Date in PHP?

how to get month from date in php and display it. The PHP date function is used to format a date. here we can learn to main 5 Examples.

how to get month from date in php?

Get Month Name to $Date can be done in many ways. The following source code will get month from date in php.

Example 1: PHP Get Full Month Name from Date

php_get_full_month_name_from_date.php

<?php
  
    $myJoinDt = "2022-02-02";
    $latestDt = date('F', strtotime($myJoinDt));
  
    echo $latestDt;
  
?>

Result

February

don’t miss : get day from date php

Also Read This πŸ‘‰   laravel get env variable - How to get .env variable in blade or controller?

Example 2: PHP Get Full Month Name from Current Date

php_get_full_month_name_from_current_date.php

<?php
  
    $latestDt = date('F');
  
    echo $latestDt;
  
?>

Result

November

Example 3: PHP Get Short Month Name from Date

php_get_short_month_name_from_date.php

<?php
  
    $myJoinDt = "2022-02-02";
    $latestDt = date('M', strtotime($myJoinDt));
  
    echo $latestDt;
  
?>

Result

Feb

Example 4: PHP Get Short Month Name from Current Date

php_get_short_month_name_from_current_date.php

<?php
  
    $latestDt = date('M');
  
    echo $latestDt;
  
?>

Result

Nov

Example 5: PHP Get Month Name from Number

php_get_month_name_from_number.php

<?php
  
    $monthNumber  = 4;
    $monthName = date('F', mktime(0, 0, 0, $monthNumber, 10));
  
    echo $monthName;
  
?>

Result

April

I hope you get an idea about how to get month from date in php?.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.