[英]Version difference for strtotime('first day of last month')?
In a script that contains 在包含的脚本中
date('Y-m-d', strtotime('first day of last month'))
in version 5.3.10 (localhost) I get, for example, '2012-03-01'. 在版本5.3.10(localhost)中,我得到了例如'2012-03-01'。
in version 5.2.17 (remote host) I get '1969-12-31'. 在版本5.2.17(远程主机)中我得到'1969-12-31'。
Is there an expression that will return expected (eg, '2012-03-01') results for both versions? 是否有表达式会返回两个版本的预期结果(例如,'2012-03-01')?
date('Y-m-d', strtotime('first day of -1 month'))
适用于PHP 7.0
这是PHP 5.2.17中的一个已知错误
As simple as: 很简单:
date('Y-m-01')
The first day of any month always is 1. 任何月份的第一天总是1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.