$last_month = date('Y-m', strtotime('last month')); $last['first'] = $last_month . '-01 00:00:00'; $last['end'] = date(‘Y-m-d H:i:s’, strtotime("$last_month +1 month -1 day +23 hours +59 minutes +59 seconds"));