Add hours in PHP -
I have a few hours in the following format from the database and try to know how to add a loop.
ID hours 1 2:23:40 2 4:20:30 3 1:10:20 while ($ stmt-> fet ()) {$ totalhours + = $ work_hours; } Copying $ totalhouses;
Any ideas how can I add them, so that I get hours with minutes and seconds?
Thanks, Raj
Convert everything in seconds, Add together, then convert that time to hours. One easy way to note is, it will not work well with the total> 24 hours.
while ($ stmt-> fetch ()) {$ totalhours + = strtotime ($ working group); } $ Totalhours = date ('H: i: s', $ totalhors);
Comments
Post a Comment