Skip to content

Instantly share code, notes, and snippets.

@Ref-Bit
Last active December 9, 2020 07:29
Show Gist options
  • Save Ref-Bit/cb3911cf6541040cc551705392b4d18e to your computer and use it in GitHub Desktop.
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".
const anotherConvertFloatToHHMMSS = secs => new Date(secs * 1000).toISOString().substr(11, 8);
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