PHP使用strtotime("-1 month", time())得到上个月是错的

今天是5月30号,使用strtotime("-1 month", time())得到的不是4月份,而是5月份。

解决方法是可以把时间戳先转换成年月,再减一月

$startTime = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month',strtotime(date('Y-m',time())))));

猜你喜欢

转载自blog.csdn.net/sinat_33541627/article/details/83582752