How to sum up time in php? -
this question has answer here:
- php add 2 time variables 7 answers
how sum time in php. example have series of time duration logs:
00:10:00 00:30:10 01:00:50
the total should 1 hour , 41 minutes here code:
$log_in = new datetime($log->log_in); $log_out = new datetime($log->log_out); $diff = $log_out->diff($log_in); $total += strtotime($diff->format('%h:%i:%s')); echo $diff->format('%h:%i:%s');
convert time timestamp using strtotime() function. manipulate time according need , result in terms of seconds.
once seconds. hour
$hour = $diff % 3600
for minute
$minute = ($diff - ( $hour *3600))%60;
Comments
Post a Comment