PHP Add Up Hours, Minutes, Seconds

后端 未结 4 1068
清歌不尽
清歌不尽 2020-12-11 22:19

Given a series of hours, minutes, and seconds (ex: 01:30:00 or 00:30:00), I would like to add up each and convert the sum to seconds.

For example, if the total time

4条回答
  •  星月不相逢
    2020-12-11 23:13

    $timestr = '00:30:00';
    
    $parts = explode(':', $timestr);
    
    $seconds = ($parts[0] * 60 * 60) + ($parts[1] * 60) + $parts[2];
    

提交回复
热议问题