我試圖計算兩個日期之間的差異並將結果存儲在會話中,然後再使用它。問題是當我顯示結果時顯示0
。這裏是我想:計算兩個日期之間的差異並存儲在會話中
$created = ('y:m:d'); // $created comes from db where the row is DATETIME
$startTimeStamp = strtotime($created);
$Today=date('y:m:d');
$timeDiff = abs($Today - $startTimeStamp);
$numberDays = $timeDiff/86400;
$numberDays = intval($numberDays);
$_SESSION['created'] = $numberDays;
'$ Today'是一個字符串,不是時間戳。 '的strtotime($今天)'。 –
@ b0s3,謝謝。傻我.. – John