<?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);`
?>`
在我杀死它后,它向我显示"不是日期格式",如何解决这个问题?
更改:
$date = new DateTime("$start");
自
$date = new DateTime($start);
和
$otherday=OtherDAY("$start",'15');
自
$otherday=OtherDAY($start,'15');
您没有传入变量的值,而是将其作为字符串传入