Created
February 24, 2017 15:53
-
-
Save jeystaats/2130dc6d7424eb6904e3c9c51f61400b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toHHMMSS(sec) { | |
let sec_num = parseInt(sec, 10); // don't forget the second parm | |
let hours = Math.floor(sec_num / 3600); | |
let minutes = Math.floor((sec_num - (hours * 3600)) / 60); | |
let seconds = sec_num - (hours * 3600) - (minutes * 60); | |
let Ohours = hours + ''; | |
let Ominutes = minutes + ''; | |
let Oseconds = seconds + ''; | |
if (hours < 10) { | |
Ohours = "0" + hours; | |
} | |
if (minutes < 10) { | |
Ominutes = "0" + minutes; | |
} | |
if (seconds < 10) { | |
Oseconds = "0" + seconds; | |
} | |
var time = Ohours + ':' + Ominutes + ':' + Oseconds; | |
return time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment