Calculate difference between 2 times in hours in PHP

后端 未结 7 725
無奈伤痛
無奈伤痛 2020-12-10 20:11

I have two times - For eg- the current time - 08:24 and date is 02/01/2013 in dd/mm/yyyy format and I have another time at 13:46 and date is 31/12/2012 . So, how can I cal

7条回答
  •  长情又很酷
    2020-12-10 20:34

    Just putting this here, for anyone who needs to find the difference between two dates/timestamps in Hours, Minutes 'AND' Seconds!!

    $futureDate_raw = '12/13/2018'; // This is your finish date.
    $fdate = strtotime($futureDate_raw);
    
    $hours   = (($fdate - time()) / 3600;
    $mins    = (($fdate - time()) % 3600) / 60;
    $seconds = ((($fdate- time()) % 3600) % 60);
    

提交回复
热议问题