使用下面的PHP代碼,我期望得到'2'作爲我的輸出。但我得到'1'。PHP DateDiff問題
有誰知道這是爲什麼?
$returndate = preg_replace('#(\d+)/(\d+)/(\d+)#', '$3-$2-$1', '2011-03-28');
$departdate = preg_replace('#(\d+)/(\d+)/(\d+)#', '$3-$2-$1', '2011-03-26');
$diff = abs(strtotime($returndate) - strtotime($departdate));
$years = floor($diff/(365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24)/(30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
echo $days; // expecting 2, but get 1
非常感謝您的任何幫助。
很多,非常感謝Jared,完美地工作。 – michaelmcgurk 2011-03-23 20:30:51