添加日期的天数 [英] Add number of days to a date
问题描述
我正在使用以下代码:
$ i = 30;
echo $ date = strtotime(date(Y-m-d,strtotime($ date))。+。$ i。days);
但是,没有获得正确的日期,我得到这个:
2592000
请建议。
回覆日期('Ym-d',strtotime(+ 30天)); b>
strtotime
希望给出一个包含美国英文日期格式的字符串,并尝试将该格式解析为Unix时间戳(自1970年1月1日00:00以来的秒数:00 UTC),相对于现在给出的时间戳,或当前时间,如果现在不提供。
while date
返回根据给定格式的字符串格式化的字符串,使用给定的整数时间戳或
请参阅手册页
及其功能签名。
I want to add number of days to current date: I am using following code:
$i=30;
echo $date = strtotime(date("Y-m-d", strtotime($date)) . " +".$i."days");
But instead of getting proper date i am getting this: 2592000
Please suggest.
This should be
echo date('Y-m-d', strtotime("+30 days"));
strtotime
expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.
while date
Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given.
See the manual pages for
and their function signatures.
这篇关于添加日期的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!