Another solution would be to go through the difference in integer values ββof Unix-timestamp (in seconds).
<?php $start = strtotime('10-09-2019 12:01:00'); $end = strtotime('12-09-2019 13:16:00'); $hours = intval(($end - $start)/3600); echo $hours.' hours'; //in hours //If you want it in minutes, you can divide the difference by 60 instead $mins = (int)(($end - $start) / 60); echo $mins.' minutues'.'<br>'; ?>
This solution would be better if source dates are stored in Unix-timestamp format.
source share