How to calculate minute difference between two date-times in PHP?
+8
A:
Subtract the past-most one from the future-most one and divide by 60.
Times are done in unix format so they're just a big number showing the number of seconds from January 1 1970 00:00:00 GMT
Oli
2008-12-13 13:23:44
+2
A:
Here is the answer:
print("<?php
$to_time=strtotime("2008-12-13 10:42:00");
$from_time=strtotime("2008-12-13 10:21:00");
echo round(abs($to_time - $from_time) / 60,2)." minute";
?>");
@user38526 thank's, was the best solution...
Harish Kurup
2010-09-22 07:26:40
+2
A:
<?php
$date1 = time();
sleep(2000);
$date2 = time();
$mins = ($date2 - $date1) / 60;
echo $mins;
?>
Tom
2008-12-13 15:49:50
A:
How would I do this if my "times" are stored as data in cells?
[eg: check-out time minus check-in time = wait time]
Travis
2009-09-16 23:26:47
A:
Thanks....this is the best, simple, smart code I have seen so far for this problem of date difference.
coder
2010-06-18 07:07:24
A:
you can find answer this URL http://erandaisuru.blogspot.com/2009/10/hot-to-get-time-difference-using-php.html
Jayathissa
2010-10-17 06:12:18