$last_month_first_day=strtotime('first day of last month'); $no_of_days=date('t',$last_month_first_day); $date_value=$last_month_first_day; for($i=0;$i<$no_of_days;$i++) { echo date('Ym-d',$date_value)."<br>"; $date_value=strtotime("+1 day",$date_value); }
This code will print what you want.
First Date:
echo date('Ym-d',strtotime('first day of last month'));
Last date:
echo date('Ym-d',strtotime('last day of last month'));
source share