【发布时间】:2012-05-10 11:22:24
【问题描述】:
我正在尝试编写一个函数来检查“已完成的课程”是否是四天前。例如,我如何检查所述课程是否在该时间范围内。如果昨天完成,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 日完成的课程。我猜 5 月 7 日上完的课应该是真的吧?
【问题讨论】:
-
$finishedLesson['deadline'] 是什么数据类型,是 unix 时间戳吗?
-
当您说 4 天前时,您是指正好在 4 天前和 5 天前之间(即 6:th 下午 1:27 和 7:th 下午 1:27 之间)还是做您是指 6 号当天的任何时间?