本文介绍了strtotime返回'-1个月'的时间戳不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用CCK日期字段。在Mart(> = 29 Mar)结束时的strtotime将为strtotime('1个月')返回不正确的结果。 //当前日期3月30日 $ time = strtotime(' - 1个月'); 打印日期('m / d / Y',$ time);
任何想法?
解决方案这是直观的,但是:
03/30/2011 - 1个月= 02/30 / 2011 => 03/02/2011同样的原因:
03/31/2011 + 1个月= 04/31/2011 => 05/01/2011没有办法我知道得到上个月/下个月的同一天使用 PHP的相对日期/时间格式。
I've using CCK date field. strtotime at end of Mart (>=29 Mar) will return incorrect result for strtotime('1- month').
// Current date Mar 30 $time = strtotime('-1 month'); print date('m/d/Y', $time);Any ideas ?
解决方案This is counter intuitive, but:
03/30/2011 - 1 month = 02/30/2011 => 03/02/2011For the same reason:
03/31/2011 + 1 month = 04/31/2011 => 05/01/2011There is no way I know of to get "same day last / next month" using the relative date/time formats of PHP.
更多推荐
strtotime返回'
发布评论