Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
secondsToHourMinuteSecond(totalSeconds) {
let hour = Math.floor(totalSeconds / 3600);
let minute = Math.floor(totalSeconds % 3600 / 60);
let seconds = Math.floor(totalSeconds % 3600 % 60);
return `${('0' + hour).slice(-2)}:${('0' + minute).slice(-2)}:${('0' + seconds).slice(-2)}`
}
/*
returns total seconds to hh:mm:ss value.
e.g. 133 seconds = 00:02:13
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment