I want to get time difference in HH:MM:SS format below is the code
if time diff in seconds it should display l like 00:00:35 In minutes :00:30:35 In Hrs :01:30:35
You can use strtotime() for time calculation. Here is an example:
$time1 = strtotime('10:55:59');
$time2 = strtotime('10:56:00');
$diff = $time2 - $time1;
echo 'Time 1: '.date('H:i:s', $time1).'\n';
echo 'Time 2: '.date('H:i:s', $time2).'\n';
if($diff){
echo 'Diff: '.date('H:i:s', $diff);
}else{
echo 'No Diff.';
}
Output:
Time 1: 09:00:59
Time 2: 09:01:00
Diff: 00:00:01