我想寫一個函數來檢查一個「完成的課程」是否在四天前。例如,如何檢查課程是否在該時間範圍內。如果它是在昨天,2天前,3天前,4天前完成的,那麼它是在「4天前」的時間範圍內。如何在PHP中檢查4天前是否有東西?
如何檢查?
到目前爲止,我已經做了:
$time = time();
$fourDays = 345600;
$threeDays = 259200;
$lastLesson = $ml->getLesson($cid, $time, true);
$lastLessonDate = $lastLesson['deadline'];
$displayLastLesson = false;
if ($lastLessonDate + $fourDays < $time)
{
$displayLastLesson = true;
//We print lesson that was finished less than 4 days ago
}
else
{
//We print lesson that is in the next 3 days
}
眼下,如果語句保持擊球真的,是不是我想要的,因爲我有一個在5月3日結束的一課。 5月7日結束的課程應該是真的嗎?
什麼數據類型爲$ finishedLesson [ '最後期限'],它是一個UNIX時間戳? – gunnx
'strtotime(' - 4 days')' – Sarfraz
當你說4天前,你的意思是正好在4天前和5天前(即在6:1下午1:27和7: th)還是你的意思是在6日的任何時候? –