Hannoun Yassir Hannoun Yassir - 1 year ago 113
Javascript Question

Convert seconds to HH-MM-SS with JavaScript?

How can I convert seconds to an

HH-MM-SS
string using JavaScript?

Answer Source

Don't you know datejs? it is a must know.

Using datejs, just write something like:

(new Date).clearTime()
          .addSeconds(15457)
          .toString('H:mm:ss');

--update

Nowadays date.js is outdated and not maintained, so use "Moment.js", which is much better as pointed out by T.J. Crowder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download