Mar*_*tin 18 php date strtotime
今天是12月31日但是strtotime("-1 months")12月返回:
echo date("Y-m", strtotime("-1 months"));
Run Code Online (Sandbox Code Playgroud)
同样的 strtotime("last month")
我怎样才能正确返回上个月(11月)?
sal*_*the 31
strtotime("first day of last month")
Run Code Online (Sandbox Code Playgroud)
这first day of是相对格式手册页中详述的重要部分.
示例:http://codepad.viper-7.com/dB35q8(今天的硬编码日期)
Ola*_*che 10
strtotime("-1 months")会2012-11-31,但是没有11月31日.这是过去的一天2012-11-30,这给了2012-12-01.当你这样做时,你会看到它
echo date("Y-m-d", strtotime("-1 months"));
Run Code Online (Sandbox Code Playgroud)
给出输出
2012年12月1日
请参阅键盘