Last active
December 9, 2020 07:29
-
-
Save Ref-Bit/cb3911cf6541040cc551705392b4d18e to your computer and use it in GitHub Desktop.
This is a helper function to convert a float number to time format "hh:mm:ss".
This file contains hidden or 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 anotherConvertFloatToHHMMSS = secs => new Date(secs * 1000).toISOString().substr(11, 8); |
This file contains hidden or 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 convertSecondsToHHMMSS = secs => { | |
const format = val => `0${Math.floor(val)}`.slice(-2); | |
const mins = (secs % 3600) / 60; | |
const hrs = secs / 3600; | |
return [hrs, mins, secs % 60].map(format).join(':'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment