Skip to content

Instantly share code, notes, and snippets.

@neatshell
Created May 8, 2019 12:06
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 neatshell/348538381d83c65a32ca6cf56c5524cc to your computer and use it in GitHub Desktop.
Save neatshell/348538381d83c65a32ca6cf56c5524cc to your computer and use it in GitHub Desktop.
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