How do I subtract minutes from hours in PHP using seconds?
I am using the following code to try and subtract minutes from seconds. These are all represented using seconds.
//Hours worked in seconds (8 hrs) $hours_worked = 28800; //Break time in seconds (15 mins) $break_mins = 1500; $total_hours = round(($hours_worked - $break_mins) / 60 / 60 , 2); echo $total_hours;
I was expecting the output to be "7.75" as 15 minutes = 0.25 of an hour, right?
Am I missing something obvious here? I must be!
I have been trying to figure this out for hours now and cant wrap my head round what I'm doing wrong. Any help would be greatly appreciated.