PHP strtotime:获取上个月 [英] PHP strtotime: Get previous month
本文介绍了PHP strtotime:获取上个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
今天是12月31日,但 strtotime( - 1个月)
返回十二月:
Today is December, 31st but strtotime("-1 months")
returns December:
echo date("Y-m", strtotime("-1 months"));
相同于 strtotime(上个月)
如何正确地返回上个月(11月)?
How can I properly return the previous month (November)?
测试: http://codepad.viper-7.com/XvMaMB
推荐答案
strtotime("first day of last month")
c $ c的第一天是相对格式手册页。
示例: http://codepad.viper-7.com/dB35q8 (今天的硬编码)
Example: http://codepad.viper-7.com/dB35q8 (with hard-coded today's date)
这篇关于PHP strtotime:获取上个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文