只有一个问题:是否可以比较日期时间格式和时间格式?
我有表employee_attendance
(日期时间类型)和表employee_schedule
(时间类型),这是为了确定员工是否迟到。
请检查我的代码。
$CheckInNew = strtotime('2013-06-05 08:47:53');
$OnDutyTimeNew = strtotime('08:00:00');
if($CheckIn > $OnDutyTimeNew){
// confirming that the employee is late
} else {
// confirming that the employee is NOT late
}
有什么想法吗?
谢谢
最佳答案
试试这个:
$CheckInNew = date('B',strtotime('2013-06-05 08:47:53'));
$OnDutyTimeNew = date('B',strtotime('08:00:00'));
if ($CheckInNew > $OnDutyTimeNew)
echo 'late!';
else
echo 'early!';
我将 be 用作 Internet Swatch
时间的关键字。有关更多信息,here's the link
更新: PHPFiddle
关于php - 如何在php mysql中比较日期时间和时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16929777/