Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created September 14, 2019 14:46
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 leemartin/347f06a35f3a7df4b7f438c8fafb11c2 to your computer and use it in GitHub Desktop.
Save leemartin/347f06a35f3a7df4b7f438c8fafb11c2 to your computer and use it in GitHub Desktop.
Milliseconds to Timecode
let msToTime = (milliseconds) => {
let ms = milliseconds % 1000
let s = (milliseconds - ms) / 1000
let secs = s % 60
if (secs < 10) {
secs = `0${secs}`
}
s = (s - secs) / 60
let mins = s % 60
if (mins < 10) {
mins = `0${mins}`
}
let hrs = (s - mins) / 60
return mins + ':' + secs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment