$last_month = date(‘Ymd’,strtotime(‘-1 month’,strtotime(‘2021-03-01’))); // 前1个月
$last_month2 = date(‘Ymd’,strtotime(‘-1 month’,strtotime(‘2021-03-30’))); // 前1个月
$last_month3 = date(‘Ymd’,strtotime(‘-1 month’,strtotime(‘2021-08-31’))); // 前1个月
$last_month4 = date(‘Ymd’,strtotime(‘-1 month’,strtotime(‘2021-01-02’))); // 前1个月
$last_month5 = date(‘Ymd’,strtotime(‘-1 month’,strtotime(‘2021-09-30’))); // 前1个月
$last_month6 = date(‘Ymd’,strtotime(‘-1 month’,strtotime(‘2021-07-31’))); // 前1个月
\Log::info(‘test_last_month:’.$last_month.‘ last_month2:’.$last_month2.‘ last_month3:’.$last_month3.‘ last_month4:’.$last_month4.‘ last_month5:’.$last_month5.‘ last_month6:’.$last_month6);
local.INFO: test_last_month:20210201 last_month2:20210302 last_month3:20210731 last_month4:20201202 last_month5:20210830 last_month6:20210701
结论:用1号的字符串再-1 month就没事了