mysql - How I can determine the time between dates with php and mysl? -
i want determine how time elapsed between dates, have different tables have initial time example [2016-05-28] , [13:36:42] , other time [2016-05-31] , [09:05:18]
i want know, how can determine time elapsed, in case have "two days 20 hours"
the language using php, mysql, framework , angularjs, recommendable side make it
simple php code:
<?php $dates = ['2016-05-12 05:33:02','2016-07-17 05:00:12']; $time_diff = strtotime($dates[0]) - strtotime($dates[1]); $time_diff<0?$time_diff*=-1:null; print floor($time_diff/86400) . ' days ' . floor(($time_diff % 86400) / 3600) . ' hours ' . floor(($time_diff % 3600) / 60) . ' minutes'; ?>
prints: 65 days 23 hours 27 minutes
Comments
Post a Comment