假设$start_date = 2017-12-13
。
我想知道10天后应该约会的日期。
我试过这个strtotime("$start_date +10 days")
,输出是1512946800
您将时间戳作为值,现在您只需要将其格式化为最新版本。
date("y-m-d HH:mi:ss", strtotime("$start_date +10 days"))
date("Y-m-d", strtotime("$end_date -10 days")); //for minus
那应该照顾它。
使用DateTime更容易
$start_date = "2017-12-13";
$date = new DateTime($start_date);
echo $date->modify('+10 day')->format('Y-m-d');
echo date("Y-m-d", strtotime("+10 days", strtotime($start_date)));
你试试如上。从“+10天”替换为您想要的值,以获得您希望添加的天数。
使用php strtotime()
函数获取10天后的日期。 strtotime()
函数它给出了未来日期的unix时间戳,现在使用date()
函数格式化它
$start_date = "2017-12-13";
$future_date =strtotime("$start_date +10 days");//it will give the unix timestamp of the future date, now format it using date() function as
$future_date=date("Y-m-d H:i:s", $future_date);
查看qazxsw poi手册