please help me with strtotime . TQ in advance
Posted: Mon Dec 21, 2009 8:51 pm
Hi all,
I have this function to calculate time different
the function works well but if the $hour2 is 24:00, $hours[1] will appear as 0730.
I really dont understand how it becomes 0730 instead of 2400 or 0000.
this is the output if i selected $hour1= 17:00, $hour2=24:00
17
0017:00bb24:00bb17.00aa07.30aa1020n450n14.50
Please help me...
Thank you
I have this function to calculate time different
Code: Select all
function timeDif($hour1,$hour2){
echo $hour1; echo "bb";
echo $hour2; echo "bb";
$dif = 0;
$hours[0] = date("H.i",strtotime($hour1));//"13:30:24"
// $hours[0] = date("H.i",strtotime($input_start_hour));
$hours[1] = date("H.i",strtotime($hour2));
// $hours[1] = date("H.i",strtotime($input_end_hour));
echo $hours[0]; echo "aa";
echo $hours[1]; echo "aa";
$hours[0] = ((int)$hours[0])*60 + ($hours[0]-((int)$hours[0]))*100;
$hours[1] = ((int)$hours[1])*60 + ($hours[1]-((int)$hours[1]))*100;
echo $hours[0]; echo "n";
echo $hours[1]; echo "n";
if($hours[0] > $hours[1]) {
$hours[1] += 24*60;
}
$dif = sprintf("%.2f",($hours[1] - $hours[0]) / 60);
echo $dif;
return $dif;
}
$total_hours = timeDif($input_start_hour,$input_end_hour);I really dont understand how it becomes 0730 instead of 2400 or 0000.
this is the output if i selected $hour1= 17:00, $hour2=24:00
17
Please help me...
Thank you