/ 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
Expand |
Embed | Plain Text
function timer_format(sec) { 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:/, ''); }
You need to login to post a comment.
