Created
May 8, 2019 12:06
-
-
Save neatshell/348538381d83c65a32ca6cf56c5524cc 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
module.exports = (millis) => { | |
let seconds = (millis / 1000).toFixed(0); | |
let minutes = Math.floor(seconds / 60); | |
let hours = ''; | |
if (minutes > 59) { | |
hours = Math.floor(minutes / 60); | |
hours = (hours >= 10) ? hours : '0' + hours; | |
minutes = minutes - (hours * 60); | |
minutes = (minutes >= 10) ? minutes : '0' + minutes; | |
} else if (minutes < 10) { | |
minutes = '0' + minutes; | |
} | |
seconds = Math.floor(seconds % 60); | |
seconds = (seconds >= 10) ? seconds : '0' + seconds; | |
if (hours !== '') { | |
return hours + ':' + minutes + ':' + seconds; | |
} | |
return minutes + ':' + seconds; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment