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