how to display current month in PHP?

Today, We want to share with you current month in php.In this post we will show you php strtotime, hear for php date we will give you demo and example for implement.In this post, we will learn about php display current Date & time with an example.

PHP get the current month of a date

use the default date() function of PHP

Example 1: get current month

<?php 
$get_month = date('m');

if($get_month == 12){
   echo "<br />December is the month :)";
} else {
   echo "<br /> The month is probably not December";
}
?>

Example 2: Full version:

<? echo date('F Y'); ?>

Example 3: Short version:

<? echo date('M Y'); ?>

How to get the first and last date of current month?


$first_day_this_month = date('m-01-Y'); 
$last_day_this_month  = date('m-t-Y');

$last_day_april_2010 = date('m-t-Y', strtotime('April 21, 2021'));

how to get the first and last days of a given month?

<?php

$day_this_month = '2021-02-04';

// First day of the month.
echo date('Y-m-01', strtotime($day_this_month));

// Last day of the month.
echo date('Y-m-t', strtotime($day_this_month));

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

Also Read This 👉   Simple PHP Convert Object To An Array Examples