Posted By

nkm on 04/27/10


time format timer conversion convert seconds elapsed countDown Stopwatch

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Timer format

 / Published in: JavaScript

Formats a time in Numeric format into Timer format (HH:MM:SS). - Rounds values after conversion - Displays negative values (-HH:MM:SS) - Only displays the hours if necessary - Fails gracefully

  1. function timer_format(sec) {
  3. return (sec<0?'-':'')+(new Date(Math.abs(Math.round(sec))*1000 || 0)).toUTCString().match(/[0-9]{2}:[0-9]{2}:[0-9]{2}/).toString().replace(/^00:/, '');
  4. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: on September 20, 2018

the 8 best side by refrigerator under 1000 the8best

You need to login to post a comment.