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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -