Hi have problem of adding total number of hours and minutes in a recordset
My record is like
From time to time total time
9:30 AM 11:30 AM 2:00
9:15 AM 10:15 AM 1:00
----------------------------------
3:00 (Not worked)
----------------------------------
I have code for adding two given time like start time and end time, but i need total number of hours worked. Please help in this.
Following is the code for two given time
$sum=AddPlayTime($tims,$tims1);// Adding two given hours and minutes like 1:30 and 2:30 gives 4:00
function AddPlayTime ($oldPlayTime, $PlayTimeToAdd) {
$pieces = split(':', $oldPlayTime);
$hours=$pieces[0];
$hours=str_replace("00","12",$hours);
$minutes=$pieces[1];
$oldPlayTime=$hours.":".$minutes;
$pieces = split(':', $PlayTimeToAdd);
$hours=$pieces[0];
$hours=str_replace("00","12",$hours);
$minutes=$pieces[1];
$str = $str.$minutes." minute ";
$str = "01/01/2010 ".$oldPlayTime." am + ".$hours." hour ".$minutes." minute ";
if (($timestamp = strtotime($str)) === false) {
return false;
} else {
$sum=date('h:i', $timestamp);
$pieces = split(':', $sum);
$hours=$pieces[0];
$hours=str_replace("12","00",$hours);
$minutes=$pieces[1];
$sum=$hours.":".$minutes;
return $sum;
}
}