I'm working on the application where I want to calculate the total late hours of an employee from a set of records between the employee timing shift?
Example Of Employee Time Shift
Shift Start: 01:00:00
Shift End: 09:00:00
Php Code
// example 1
error_reporting('0');
$time1 = "01:00:00";
$time2 = "09:00:00";
date_default_timezone_set('Asia/Karachi');
echo "Time difference: ".get_time_difference($time1, $time2)." hours<br/>";
function get_time_difference($time1, $time2)
{
$date = date('h:i:s a', time());
$time1 = strtotime("1/1/1980 $time1");
$time2 = strtotime("1/1/1980 $time2");
$totalshifttime = ($time2 -$time1) / 3600;
$totallate= $totalshifttime - $date ;
return $totallate;
}?
Let's support if ABC employee clock in at 2 pm then should automatically display 1 hour late current function is showing 7 hours late?