可能重复:
How to get previous month and year relative to today, using strtotime and date?
今天是12月31日,但strtotime("-1 months")
返回12月:
echo date("Y-m", strtotime("-1 months"));
strtotime("last month")
也是如此
如何正确返回上个月(11月份)?
发布于 2012-12-31 22:17:54
strtotime("first day of last month")
如Relative Formats手册页所述,first day of
是重要的部分。
示例:http://codepad.viper-7.com/dB35q8 (具有硬编码的今天日期)
发布于 2012-12-31 22:26:23
strtotime("-1 months")
应该是2012-11-31
,但没有11月31号。这比提供2012-12-01
的2012-11-30
晚了一天。当你这样做的时候,你会看到它。
echo date("Y-m-d", strtotime("-1 months"));
以输出形式给出
2012-12-01
请参阅codepad
https://stackoverflow.com/questions/14102625
复制相似问题