<?php
// the example below is to calculate the hours of work for a week
include('CountHour.class.php');
$time = new CountHour();
$day[0] = '08:00:27,17:05:23';
$day[1] = '07:50:25,17:12:12';
$day[2] = '07:55:34,17:05:00';
$day[3] = '08:01:22,17:03:54';
$day[4] = '08:03:14,17:02:28';
$day[5] = '07:59:07,17:11:11';
$day[6] = '08:10:43,16:01:20';
// rest time
$rest_time = '01:00:00'; // lenght of rest time, this is same with 1 hour
$rest_time1 = $time->seconds($rest_time); // convert rest time to seconds mode
// define hour, minute and second of rest time
$restt = $time->define_hour($rest_time);
// count of working days
$count_day = count($day);
for($i=0;$i<$count_day;$i++) {
// get the entrance and home absent
$hour[$i] = explode(',',$day[$i]);
$diff_seconds[$i] = $time->diff_seconds($hour[$i][0],$hour[$i][1])-$rest_time1;
$diff[$i] = $time->std($diff_seconds[$i]);
$j = $i+1;
echo 'Day-'.$j.'. Entrance = '.$hour[$i][0].' Home absent = '.$hour[$i][1].' Working hours = '.$diff[$i].'<br />';
}
// count of working hours
$total_seconds = array_sum($diff_seconds);
$total = $time->std($total_seconds);
$totall = $time->define_hour($total);
echo '<br />Count of working hours = '.$total.' ('.$totall.')<br />
<br />
* working hours = hours between the entrance to the home absent reduced hours of the rest ('.$restt.')';
?>
|