I have the following code:
$sql = "Select * from time where user_id='$resultsetinfo[id]' and date='$weekdate'";
//echo "$sql<br>";
$result = mysql_query($sql);
$diffs = array();
$total = 0;
while($row = mysql_fetch_array($result))
{
$start = strtotime($row['time_in']);
$end = strtotime($row['time_out']);
array_push($diffs, ($end-$start));
}
foreach($diffs as $span)
{
$total = $total+$span;
}
$hours = floor($total/(60*60));
$total = $total-($hours*(60*60));
$minutes = floor($total/(60));
$seconds = $total-($minutes*60);
$total = "$hours hours, $minutes minutes";
echo "<td>$total</td>";
$totalhours = $hours + $totalhours;
$totalmins = $minutes + $totalmins;
$totaltime = "$totalhours hours, $totalmins minutes";
The problem with this is it doesn't add any time to the hours if the minutes is over 60 minutes. So if I have a time like 2 hours 110 minutes I would like it to be 3 hours 50 minutes. Anyone have an idea how to do this?
Thanks in advance.