Get the last day of the Month with Zend Date

When you’re creating reports you will often work with a date range, a start date and end date.  If it’s a monthly report the user will select month and pass this to the report function.

This function will then work out the start and end date, for example if the month passed in was February the start and end date would be 1st February 2012 to the 29th February 2012.  To get the last day in February, use the get method Zend_Date::MONTH_DAYS constants to return the last day of the month the 29th.

// Current Month is February 2012
$date = new Zend_Date();
$lastDayofMonth = $date->get(Zend_Date::MONTH_DAYS);

echo 'Last day of month = '. $lastDayofMonth;
This entry was posted in Managed Hosting. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>