Get amount of hours between 2 hours

If you would like to get the amount of hours between 10:00 and 12:00 then use this!

function timeDiff($firstTime,$lastTime) {
  $firstTime=strtotime($firstTime);
  $lastTime=strtotime($lastTime);
  $timeDiff=$lastTime-$firstTime;
  return $timeDiff;
}

echo (timeDiff("10:00","12:00")/60)/60;
Tags:

Leave a Reply

Your email address will not be published.