Difference between dates

前端 未结 3 390
不知归路
不知归路 2021-01-24 08:45

I want to calculate the difference between two times, one of which is the current time, and the other is just in the format HH:MM, always in the future.

If I just subtra

3条回答
  •  感情败类
    2021-01-24 09:39

    If you're on PHP 5.3+, use PHP's DateTime:

    $d1 = new DateTime('14:52:10');
    $d2 = new DateTime('12:12:10');
    
    $diff = $d1->diff( $d2 ); 
    var_dump( $diff );
    

提交回复
热议问题