Skip to content

Instantly share code, notes, and snippets.

@noudadrichem
Created March 12, 2018 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noudadrichem/69f7db4d374e83dbf4a20f0fea42a5bd to your computer and use it in GitHub Desktop.
Save noudadrichem/69f7db4d374e83dbf4a20f0fea42a5bd to your computer and use it in GitHub Desktop.
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