我正在 PHP 5.2.12 中尝试以下命令:
print (date('Y-m-d', strtotime('2009-12 last day')));
关于 php.net manual :
date('m/d/y', strtotime('2009-03 last day')); # 03/31/09
它应该显示 2009 年 3 月的最后一天 (2009-03-31) !
我的返回上个月的最后一天?为什么 ? :
2009-11-30
最佳答案
您发布的代码按照您描述的方式失败;似乎PHP手册页中的描述(如SilentGhost所述,只是用户评论)是未经验证的代码。
如果你需要给定月份的最后一天,试试这个:
date('Y-m-d', strtotime("2009-12 next month - 1 hour"));
关于PHP strtotime( YYYY-mm last day) 月休错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2510384/