我试图使今天和数据库(数组)中的字段的日期之间的日期差异(以天为单位),这是我的代码:
$date1 = date_create ($v['sipp_ed']);//this is from field in database
$date2 = new DateTime();
$intval = date_diff ($date1, $date2);
echo $intval->format("Diiference is %a days");
Run Code Online (Sandbox Code Playgroud)
但总是收到错误“不推荐将 null 传递给字符串类型的参数 #1 ($datetime)”。我曾多次尝试使用其他函数,如 strtotime、date 和 getdate,但总是失败......有人可以帮助我吗?