Quantcast
Channel: JavaScript seconds to time string with format hh:mm:ss - Stack Overflow
Viewing all articles
Browse latest Browse all 49

Answer by Andy Wu for JavaScript seconds to time string with format hh:mm:ss

$
0
0
s2t=function (t){  return parseInt(t/86400)+'d '+(new Date(t%86400*1000)).toUTCString().replace(/.*(\d{2}):(\d{2}):(\d{2}).*/, "$1h $2m $3s");}s2t(123456);

result:

1d 10h 17m 36s

Viewing all articles
Browse latest Browse all 49

Latest Images

Trending Articles



Latest Images