Nov 152012
 

Google – last day of month php – and you’ll get over 15,000,000 results.  It’s amazing how many people have searched for this & how many roundabout ways there are to accomplish what should be a simple task.

Here is the simplest way (that I know of) to get the last day of the month using PHP.

Get last day of the current month

$lastday = date(‘t’,strtotime(‘today’));

 Get last day of next month

$lastday = date(‘t’,strtotime(‘next month’));

Get last day of any other month
Enter any month/day/year to get the last day of that month

$lastday = date(‘t’,strtotime(‘3/1/2009’));

If you want to display the last day of this month on your website, do the following:

<?php
echo date(‘t’,strtotime(‘today’));
?>

Sumber :  http://www.johnboy.com/blog/find-the-last-day-of-the-month-with-php