致命错误:调用未定义的方法 DateTime::add()


<?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');

您没有传入变量的值,而是将其作为字符串传入

最新更新