how to convert seconds to time format?

Posted by Dewan159 on Stack Overflow See other posts from Stack Overflow or by Dewan159
Published on 2010-10-04T14:42:12Z Indexed on 2012/06/07 16:40 UTC
Read the original article Hit count: 149

Filed under:
|
|

hi there for some reason i convert a time format like : 03:30 to seconds 3*3600 + 30*60 , now .. i wanna convert it back to it's first ( same ) format upthere ... how could that be ?

My attempt :

3*3600 + 30*60 = 12600 12600 / 60 = 210 / 60 = 3.5 , floor(3.5) = 3 = hour

now .. what about the minutes ??

considering the value can be like 19:00 or 02:51 ... i think you got the picture

and by the way, how to convert 2:0 for example to 02:00 using RegEx ?

Thanks in advance

© Stack Overflow or respective owner

Related posts about php

Related posts about time