Friday 23 May 2014

How to check current day is the last day of the month in php 0

We can simply use PHP's data() function to do this.

  •  date('t') will return the last day of the month.
  •  date('j') will return the current day of the month.

So, we can simply implement our if-else logic here to get the output.
$maxDays    =  date('t');
$currentDay =  date('j');

if($maxDays == $currentDay)
{
    echo 'Last Day of month';
}
else
{
    echo 'Not last day of the month';
}
Have any doubt, feel free to comment here!

0 comments:

Post a Comment