date('Y-m-01', strtotime('last month'));
date('Y-m-t', strtotime('last month'));
$lastDay = date('t',strtotime('last month'));
print_r($lastDay);
echo date('M Y', strtotime("-1 month"));
//to get date with time of previous month
echo date("Y-m-d H:i:s",strtotime("-1 month"));
$lastDateOfNextMonth =strtotime('last day of next month') ;
$lastDay = date('d/m/Y', $lastDateOfNextMonth);
print_r($lastDay);
<?php
$date = "2020-01-11";
$newdate = date("Y-m-d", strtotime ( '-1 month' , strtotime ( $date ) )) ;
echo $newdate;
?>
$a_date = "2009-11-23";
echo date("Y-m-t", strtotime($a_date));
$tgl = '25 january 2012';
$prevmonth = date("M Y",mktime(0,0,0,date("m", strtotime($tgl))-1,1,date("Y", strtotime($tgl))));
echo $prevmonth;
$lastOfMonth = date('Y-m-t');
if(gmdate('t') == gmdate('d')){
echo 'Last day of the month.';
}