How to get the Hours Difference (in HH:MM format) in PHP

It’s very simple to get the difference in hours using PHP

function timeDiff($firstTime,$lastTime) { $firstTime=strtotime($firstTime); $lastTime=strtotime($lastTime); $timeDiff=$lastTime-$firstTime; return $timeDiff; } echo (timeDiff("10:00","12:00")/60)/60;
Code language: PHP (php)
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments