<?php
function OtherDAY($start,$total){
$date = new DateTime("$start");
$date->add(new DateInterval('P'.$total.'D'));
$finish=$date->format('Y-m-d');
return $finish;
}
$start=date("Y-m-d");
$otherday=OtherDAY("$start",'15');
die($otherday);`
?>`
我杀了它之后显示“不是日期格式”,如何解决此问题?
答案 0 :(得分:0)
变化:
$date = new DateTime("$start");
要
$date = new DateTime($start);
和
$otherday=OtherDAY("$start",'15');
要
$otherday=OtherDAY($start,'15');
您没有传递变量的值,因为您将其作为字符串传递