我只是试图从当前日期08/29/2015 @ 11:19am (UTC)
减去6个月和5个月并得到相同的结果
以下是代码示例:
date("M, Y", strtotime("-5 months")) // returns Mar, 2015
date("M, Y", strtotime("-6 months")) // returns Mar, 2015
是否因为白天节约了?我想不。
答案 0 :(得分:2)
date("M, Y", strtotime("-6 months"))
简单地返回Mar, 2015
,因为今年2月没有。因此下个月需要三月。
要解决此问题,请务必从该月的第一天开始,例如
echo date("M, Y", strtotime("-6 months", strtotime(date('Y-m-01'))));
//^^^^^^^^^^^^^^^^^^^^^^^^^ First day of month
答案 1 :(得分:0)
这是我能找到的唯一可行选项。 How to subtract 4 months from today's date?
echo date("Ymd", mktime(0, 0, 0, date("m")-5, date("d"), date("Y")));;