Answers for "turn milliseconds to human readable string typescript"

0

turn milliseconds to human readable string typescript

public static msToTime (ms: number): string {
  const date = new Date(ms)
  const h = date.getHours()
  const m = date.getMinutes()
  const s = date.getSeconds()

  return `${h < 10 ? `0${h}` : h}:${m < 10 ? `0${m}` : m}:${s < 10 ? `0${s}` : s}`
}
Posted by: Guest on March-22-2021

Code answers related to "turn milliseconds to human readable string typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language