How do I subtract two time variables from each other with the answer as a decimal number? My time variables look like this: 07:32:00
I am looking for something like this:
$total = $start_time - $end_time
echo "$time Hours";
Output to look like this:
5.3 Hours
You cant subtract on strings. Your variable "07:32:00" is a string.
You will have to convert the time to Unix timestamp with the php function strtotime.
And you aslo have to subtract from the largest time.
Here is the solution:
echo (strtotime("15:00:00") - strtotime("11:30:00"))/(60*60);