Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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}`
}
 
PREVIOUS NEXT
Tagged: #turn #milliseconds #human #readable #string #typescript
ADD COMMENT
Topic
Name
2+5 =