我正在尝试编写一个函数来检查“完成的课程”是否是四天前。例如,我如何检查所述课程是否在该时间范围内。如果昨天完成,2天前,3天前,4天前,那是真的,因为它在“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
}
现在,if 语句一直为真,这不是我想要的,因为我有一个在 5 月 3 日完成的课程。对于 7 日完成的课程,我猜应该是这样吧?