time difference in HH:MM:SS format

后端 未结 2 910
庸人自扰
庸人自扰 2021-01-27 23:31

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

2条回答
  •  执笔经年
    2021-01-28 00:10

    use

    $hours   = $interval->format('%H'); 
    $minutes = $interval->format('%I');
    $seconds = $interval->format('%S');
    

    and concat both three for one variable

    or use $interval->format('%H:%I:%S') for single output

    //output 00:30:35
    

提交回复
热议问题