我有這樣的代碼$awal = date_create('$value[tgl_kembali]');$akhir = date_create(); // waktu sekarang$diff = date_diff($awal, $akhir); echo 'Total selisih hari : ' . $diff->days;使用這段代碼,我想獲得不同日期的表單變量,$awal該變量是數(shù)據(jù)數(shù)組$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條經(jīng)驗 獲得超13個贊
<?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 關(guān)注
- 165 瀏覽
添加回答
舉報
0/150
提交
取消