Showing posts with label previous month. Show all posts
Showing posts with label previous month. Show all posts

Saturday, January 8, 2011

get last day of the previous month in PHP

Get Last Day Of The Previous Month


$date = "2010-12-31";

list($yr,$mn,$dt)  = split('-', $date);         // separate year, month and date
$time_stamp        = mktime(0, 0, 0, $mn, 0, $yr);   // Create time stamp
$last_month_last_day = date("Y-m-t", $time_stamp);

echo "last_month : " . $last_month";
ouptut : 2010-11-30...