如何转换这样的军事时间?
07:03 --> 07:30
06:45 --> 07:00
07:36 --> 08:00
19:15 --> 19:30
18:35 --> 19:00
19:35 --> 20:00
基本上问题是,如果时间间隔为 30 分钟,您将把剩余的分钟加起来,使其成为一个完整的时间。
在我的数据库中,我必须像这样比较时间:
function check_range($get_shift, $date, $time, $id, $mode) {
$sql = "SELECT * FROM tbl_employee WHERE id = '$id'";
$result = mysql_query($sql);
$row_check_range = mysql_fetch_assoc($result);
$getShift = $row_check_range['shift'];
$sql2 = "SELECT * FROM tbl_shift WHERE shift = '$getShift'";
$result2 = mysql_query($sql2);
$row_check_range2 = mysql_fetch_assoc($result2);
$getTimeShift = $row_check_range2['timeIn'];
$actual_time_in_mode = explode(':', $time); //split time into (e.g 07, 11)
if ($mode == 'AM') {
$time_in_actual = $actual_time_in_mode[0];
} else {
$time_in_actual = $actual_time_in_mode[0];
$time_shift = explode(':', $getTimeShift);
$getTimeShift = $time_shift[0] + 12; //convert to military time
}
$getTimeShift = mktime($getTimeShift);
$actual_in_mode = mktime($time);
if ($actual_in_mode > $getTimeShift) // LATE
{
return $date.' '.$time_in_actual.':30:00';
} else {
$time_in_actual += 1;
return $date.' '.$time_in_actual.':00:00';
}
}