php - Add multiple timestamps together from mysql db then get hours and minutes -
what's best way retrieve start_time , end_time times mysql db using php , add them total of hours , minutes? example military time in db is: 18:35:19 22:05:14. easier standard or military time? in advance.
carlos,
some further information such format data stored within mysql have been helpful, there mysql queries this. seeing you've tagged php, following in php:
convert time unixtimestamp using mktime (http://php.net/manual/en/function.mktime.php)
$unixtimestamp_start = mktime($hour,$minute,$second,$month,$day,$year);
$unixtimestamp_finish = mktime($hour,$minute,$second,$month,$day,$year);
minus start time finish time.
$timediffseconds = $unixtimestamp_finish - $unixtimestamp_start;
you have amount of seconds between finish , start.
you can divide 60 have minutes
$timediffmins = $timediffseconds/60;
you can divide 60 again have hours.
$timediffhrs = $timediffmin/60;
Comments
Post a Comment