PHP get the current month of a date

PHP get the current month of a date

You need to use the default date() function of PHP to get current month. Then you can easily check it by if conditions as mentioned in the code below:

<?php 
$month = date(m);

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

Why not simply

echo date(F, Y);

? This prints November, 2017.

PHP get the current month of a date

This is a much better way of doing this

echo date(F, strtotime(m));

Leave a Reply

Your email address will not be published.