Skip to content

Instantly share code, notes, and snippets.

@fob2257
Created July 23, 2019 21:03
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 fob2257/f82261909fca2914d97afca49c6d2d32 to your computer and use it in GitHub Desktop.
Save fob2257/f82261909fca2914d97afca49c6d2d32 to your computer and use it in GitHub Desktop.
const getTotalTime = seconds => {
let hh = Math.floor(parseInt(seconds) / 3600);
let mm = Math.floor((seconds - (hh * 3600)) / 60);
let ss = seconds - (hh * 3600) - (mm * 60);
if (hh < 10) { hh = `0${hh}`; }
if (mm < 10) { mm = `0${mm}`; }
if (ss < 10) { ss = `0${ss}`; }
return `${hh}:${mm}:${ss}`;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment