PHP Get previous month and end day of last month
//Get previous month and year
$lastmonth = date(“Y-m”,mktime(0, 0, 0, date(“m”)-1, date(“d”), date(“Y”))); //eg .output 2010-09
$lastmonth = date(“Y-m”,mktime(0, 0, 0, date(“m”)-1, date(“d”), date(“Y”))); //eg .output 2010-09
//Get end date of previous month (use ‘t’)
$endDateOfLastMonth = date(“Y-m-t”, strtotime(“last month”)); //eg. output 2010-09-30
$endDateOfLastMonth = date(“Y-m-t”, strtotime(“last month”)); //eg. output 2010-09-30
No comments:
Post a Comment