I have this, but it can only display time difference in seconds or minutes or hours.
$diff = strtotime('2015-02-10 17:03:44') - strtotime(''.$row['start_time'].'');
$mins = $diff / 60;
$hrs = $mins / 60;
echo $diff." seconds<br />";
echo $mins." minutes<br />";
echo $hrs." hours<br />";
The first datetime (the end_time) is static, but will be dynamic later. Just doing it this way for testing. The start_time in this example is: 2015-02-10 17:03:14
The result of the above is:
30 seconds
0.5 minutes
0.0083333333333333 hours
Instead of showing the total difference in seconds and the total difference in minutes and the total difference in hours, I would like to show the total difference in hours, minutes and seconds, like this:
0 hours 0 minutes 30 seconds
If hours is less than 1 it should be rounded to 0, and the same for minutes. If the difference had minutes and seconds then an example of that would be:
0 hours 5 minutes 45 seconds
If the difference had all 3 then this would be an example result:
1 hour 17 minutes 10 seconds
How can I do that?