Here's how you can get the latest day for a given month:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
date('t'); // result : the lastest day of the current day $ts = time(); date('t', $ts); // result : the same result // PS : $ts is a unix timestamp so you can put any timestamp, // it will give you the latest day for the month of this timestamp date('Y-m-t'); // result : full date of the last day of the current month. Eg. 2011-07-31 date('t',strtotime('last month')); // You can use strtotime also with a valid date string |