Created
May 29, 2024 22:25
-
-
Save moriarty99779/8195c31a8e6bc2194bdb4720a7a7e987 to your computer and use it in GitHub Desktop.
Javascript - Convert seconds to HH:MM:SS
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
const secondsToHHMMSS = (seconds) => { | |
const hours = Math.floor(seconds / 3600); | |
const remainingSeconds = seconds % 3600; | |
const minutes = Math.floor(remainingSeconds / 60); | |
const remainingSecs = remainingSeconds % 60; | |
return `${hours}:${minutes}:${remainingSecs}`; | |
}; | |
document.write(secondsToHHMMSS(7320)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment