I'm currently new to PHP , and I am stuck on this problem. I cant seem to subtract the TIME IN
from employee SCHEDULE
function update_dtr($rs) {
foreach ($rs as $key => $value) {
$db=new Database ();
$db->connect();
//date_default_timezone_set('Asia/Ho_Chi_Minh');
$empShift = $db->select(array('myilogin_46.DATE_TIME_RECORDS'),'SHIFT_START'
,"ID = '".$id."' and R_STATUS = 'A'");
$sched= strtotime($empshift);
$alterin = strtotime($value['alterIN']);
if($sched>$alterin){
$late= strtotime("00:00:00");
}else{
//subtract Alterin by the scedule so i can get late in hours and minutes format
$late = $alterin - $sched;
}
$db->update_imp('myilogin_46.DATE_TIME_RECORDS',array(
'date_in'=>date('Y-m-d',strtotime($value['alterIN']))
,'time_in_info'=>'ALTERED IN'
,'time_out_info'=>'ALTERED OUT'
,'time_in'=>date('H:i',strtotime($value['alterIN']))
,'time_out'=>date('H:i',strtotime($value['alterOUT']))
,'date_out'=>date('Y-m-d',strtotime($value['alterOUT']))
,'late'=>gmdate('H:i',strtotime($late))
),"id = '".$value['dtrID']."' and id_emp = '".$value['empID']."' and R_STATUS = 'A'");
$db->disconnect();
PS: I also tried date_diff method, but it doesn't work on me. THis is what my database looks like