Created
June 20, 2019 04:04
-
-
Save Deityhub/b9aa8b867abd7cadb63709cd67fc6bc6 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
const secondsToHms = value => { | |
value = Number(value); | |
let hr = Math.floor(value / 3600), | |
min = Math.floor((value % 3600) / 60), | |
sec = Math.floor((value % 3600) % 60); | |
return ( | |
(hr > 0 ? hr + ":" + (min < 10 ? "0" : "") : "") + | |
min + | |
":" + | |
(sec < 10 ? "0" : "") + | |
sec | |
); | |
}; | |
export default secondsToHms; |
Author
Deityhub
commented
Dec 11, 2020
This is an improved version for hr min sec time format
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment