strtotime
echo date("Y-m-d",strtotime("-1 month",strtotime("2019-7-31"))); //2017-07-01 //为什么输出不是6.31呢,因为6月没有31,-1 month变成6.31后其实是7.1号。 echo date("Y-m-d",strtotime("last day of -1 month",strtotime("2019-7-31"))); //2017-06-30 echo date("Y-m-d",strtotime("first day of -1 month",strtotime("2019-7-31"))); //2017-06-01