I'm writing an application which logs time spent on a certain job, and I'v having trouble getting PHP to correctly calculate the number of hours spent.
For example, if I worked from 8:00 a.m. to 4:00 p.m., currently it would look like this (military time):
$start = 800;
$end = 1600;
$total = $end-$start;
And $total = 600, which is correct, because I spent 6 hours on the job. But if I start work at 8:30, then (in military time):
$start = 830;
$end = 1600;
$total = $end-$start;
And now $total = 770, which obviously 7 hours and 70 minutes isn't correct. All I need is to be able to determine the difference between two times within one day; I'm not doing more than one day because then it's even more complex. I'm just trying to get it to know that if I start work at 8:30 a.m., and end work at 4:00 p.m., that I worked for a toal of 5 1/2 hours. Does anyone know how?