2017-8-22 0phpcom
date_default_timezone_set('Asia/Shanghai'); $t = strtotime('2017-08-31'); echo date('Ym',strtotime('- 1 month',$t));//201707 echo date('Ym',strtotime('- 2 month',$t));//201707 // 解决方案 $first_day_of_month = date('Y-m',strtotime('2017-08-31')) . '-01 00:00:01'; $t = strtotime($first_day_of_month); echo date('Ym',strtotime('- 1 month',$t));//201707 echo date('Ym',strtotime('- 2 month',$t));//201706 echo date("Ym", strtotime("-2 month", strtotime("first day of 2017-08-31")));//201706