Function elapsedtime ($stop, $start) {
$id2 = substr($stop, 0, 1);//day when stop
$id1 = substr($start, 0, 1);//day when start
$a_1 = substr($stop, 2, 2); //hour when stop
$b_1 = substr($start, 2, 2); //hour when start
$a_2 = substr($stop, 5, 2); //minutes when stop
$b_2 = substr($start, 5, 2); //minutes when start
$a_3 = substr($stop, 8, 2); //seconds when stop
$b_3 = substr($start, 8, 2); //seconds when start
if (b_1 > $a_1 && $b_2 > $a_2 && b_3 > a_3)
{
$ide= $id2 - $id1 - 1;
$a = $a_1 - $b_1 + 23;
$b = $a_2 - $b_2 + 59;
$c = $a_3 - $b_3 + 60;}
else if ($b_1 > $a_1 && $b_2 > $a_2)
{
$ide=$id2-$id1 - 1;
$a = $a_1 - $b_1 + 23;
$b = $a_2 - $b_2 + 60;
$c = $a_3 - $b_3;}
else if ($b_1 > $a_1)
{
$ide=$id2 - $id1 - 1;
$a = $a_1 - $b_1 + 24;
$b = $a_2 - $b_2;
$c = $a_3 - $b_3;}
else if ($b_1 > $a_1 && $a_3 > $b_3)
{
$ide=$id2-$id1 - 1;
$a = $a_1 - $a_2;
$b = $a_2 - $b_2 - 1;
$c = $a_3 - $b_3 + 60;}
else if ($a==0 && $b_3 > $a_3) {
$ide= $id2-$id1;
$a = $a_1 - $b_1;
$b = $a_2-$b_2 - 1;
$c = $a_3 - $b_3 + 60;}
else if($b_2 > $a_2) {
$ide= $id2-$id1;
$a = $a_1 - $b_1 - 1;
$b = $a_2 - $b_2 + 60;
$c = $a_3 - $b_3; }
else if($b_3 > $a_3) {
$ide= $id2-$id1;
$a = $a_1 - $b_1;
$b = $a_2 - $b_2 - 1;
$c = $a_3 - $b_3 + 60; }
else if (($b_2 > $a_2) && ($b_3 > $a_3)) {
$ide= $id2-$id1;
$a = $a_1 - $b_1 - 1;
$b = $a_2 - $b_2 + 59;
$c = $a_3 - $b_3 + 60; }
else {
$ide= $id2 - $id1;
$a = $a_1 - $b_1;
$b = $a_2 - $b_2;
$c = $a_3 - $b_3;}
return $ide*24*3600 + $a*3600+ $b*60 + $c;
}
echo" the elapsed time for start 0:23:35:59 and stop: 1:10:36:53 is ";
echo elapsedtime ('1:10:36:53','0:23:35:59');
echo" secs";
echo"
";
echo" the elapsed time for start 0:23:35:59 and stop: 1:23:35:59 is ";
echo elapsedtime ('1:23:35:59','0:23:35:59');
echo" secs";
echo"
";
echo" the elapsed time for start 0:54:26:31 and stop: 0:55:36:28 is ";
echo elapsedtime ('0:55:36:28','0:54:26:31');
echo" secs";
?>