strtotime返回'

编程入门 行业动态 更新时间:2024-10-11 05:28:06
本文介绍了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/2011

For the same reason:

03/31/2011 + 1 month = 04/31/2011 => 05/01/2011

There is no way I know of to get "same day last / next month" using the relative date/time formats of PHP.

更多推荐

strtotime返回'

本文发布于:2023-11-27 11:22:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:strtotime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!