UNPKG

react-timer

Version:
15 lines (12 loc) 524 B
let SecondsTohhmmss = function(totalSeconds) { let hours = Math.floor(totalSeconds / 3600); let minutes = Math.floor((totalSeconds - (hours * 3600)) / 60); let seconds = totalSeconds - (hours * 3600) - (minutes * 60); // round seconds seconds = Math.round(seconds * 100) / 100 let result = (hours < 10 ? "0" + hours : hours); result += ":" + (minutes < 10 ? "0" + minutes : minutes); result += ":" + (seconds < 10 ? "0" + seconds : seconds); return result; } module.exports = SecondsTohhmmss;