How to a calculate hours that are worked in a day?
Employee should work 8 hours so 8 x 3600 = 28,800 second lets say the employee only works for 4 hours 4 x 3600 = 14,400 so the result would be 14,400 - 28,800 = -14,400 so how do i convert the result to hours and minutes and seconds
RESULT = - 04:00:00
also lets say 8 hours should work 8 x 3600 = 28,000 seconds lets say the employee works 12 hours 12 x 3600 = 43,200 = 43,200 seconds result would be 43,200 - 28,000 = 15,200
RESULT = + 04:00:00
<?php
$hoursworked = 4*3600
$dd = 8*3600;
echo gmdate("H:i:s", $dd%86400);
// day total
$ee =$hoursworked - $dd ;
$seconds = $ee;
$hours = floor($seconds / 3600);
$mins = floor(($seconds - $hours*3600) / 60);
$s = $seconds - ($hours*3600 + $mins*60);
$mins = ($mins<10?"0".$mins:"".$mins);
$s = ($s<10?"0".$s:"".$s);
$timea = ($hours>0?$hours.":":"").$mins.":".$s; ?>
The result I would like from the above example is -04:00:00 because the employee as only worked 4 hours and should have worked 8 Thanks