Skip to content

Instantly share code, notes, and snippets.

@saintsGrad15
Created February 17, 2024 21:17
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 saintsGrad15/acc34187da63dce88f229f9faca1ee15 to your computer and use it in GitHub Desktop.
Save saintsGrad15/acc34187da63dce88f229f9faca1ee15 to your computer and use it in GitHub Desktop.
Generate an "H:MM:SS" string from a duration of seconds
const hours = Math.floor(duration / 3600);
const minutes = String(Math.floor(duration % 3600 / 60)).padStart(2, "0");
const seconds = String(duration % 60).padStart(2, "0");
return `${hours}:${minutes}:${seconds}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment