我有这样的代码$awal = date_create('$value[tgl_kembali]');$akhir = date_create(); // waktu sekarang$diff = date_diff($awal, $akhir); echo 'Total selisih hari : ' . $diff->days;使用这段代码,我想获得不同日期的表单变量,$awal该变量是数据数组$akhir,并且我有这样的错误:Warning: date_diff() expects parameter 1 to be DateTimeInterface, bool given in C:\xampp\htdocs\Travel.remove\Travel\admin\pesanan.php on line 54Notice: Trying to get property 'days' of non-object in C:\xampp\htdocs\Travel.remove\Travel\admin\pesanan.php on line 55
1 回答
红颜莎娜
TA贡献1842条经验 获得超12个赞
<?php
$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a days');
?>
111
- 1 回答
- 0 关注
- 131 浏览
添加回答
举报
0/150
提交
取消