Here’s a simple trick to find the last day of a month using PHP.
$date_of_last_day = date("Y-m-t", mktime(0, 0, 0, $month, 1, $year));
This will give you the last day of any given month/year combination in the form YYYY-MM-DD.
For example, if you pass in a month of 2 (February) and a year of 2004, the result will be 2004-02-29 (2004 was a leap year).
Like I said, simple ?