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

  

posted on 2019-05-07 14:21  泪滴  阅读(1016)  评论(0编辑  收藏  举报