今天是3月30号,使用strtotime得到的不是2月份,而是3月份。解决方法是可以把时间戳先转换成年月,$t = date(Y-m);然后再使用strtoti
今天是3月30号,使用strtotime("-1 month", time())得到的不是2月份,而是3月份。
解决方法是可以把时间戳先转换成年月,$t = date('Y-m');然后再使用strtotime("-1 month", $t)就可以了。
在转换的时候不要使用年月日去转换,用年月转换就正确了,因为每个月的天数不一样,所以带天数在转换的时候就可能会出错。
赞
(0)
打赏
微信扫一扫
支付宝扫一扫


thymeleaf 模板布局 - 引入公共header
上一篇
2020年03月28日 12:54
springboot JPA为字段设置默认值
下一篇
2020年03月31日 08:24
这里是广告位
相关推荐
-
readfile(): Unable to find the wrapper ".http" - did you forget to enable it when you configured PHP?
readfile(): Unable to find the wrapper ".http" - did you forget to enable it when you configured PHP?
-
PHP使用strtotime("-1 month", time())得到上个月是错的
今天是3月30号,使用strtotime得到的不是2月份,而是3月份。解决方法是可以把时间戳先转换成年月,$t = date(Y-m);然后再使用strtoti