Skip to content

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)

See also  Restrict PHPMyAdmin to IP Address
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x