I am trying to create an attendance system. 
When checking, I call a function that updates the attendance in the database and calculates the hours (using Codeigniter)
public function updateAttendance($data,$id) { date_default_timezone_set('Asia/Karachi'); $attendance=array( 'check_in'=> $data['check_in'], 'check_out'=> $data['check_out'] ); $this->db->WHERE('id',$id)->update('attendance',$attendance); $this->db->query('UPDATE attendance SET hours=(HOUR(TIMEDIFF(check_out,check_in))-1) WHERE DATE(date)=\''.date('Ym-d').'\' and employee_id='.$id); return true; }
I come to the visitor with the employee ID and look at a view similar to that in the employee profile.

The problem is that I am wrong when calculating the hours, possibly due to my request. Is there a fix on request or do I need to make time in a time format, and then add all of them at the end of the month, and then get the clock from it.
source share