How to convert milliseconds to hh:mm:ss in TypeScript

1 Answer

0 votes
const milliseconds = 873708347;
 
const hhmmss = Math.floor(milliseconds / (1000 * 60 * 60)) + ":" + 
               Math.floor(milliseconds / (1000 * 60)) % 60 + ":" +
               Math.floor(milliseconds / 1000) % 60;
 
console.log(hhmmss);
   
   
   
   
/*
run:
   
"242:41:48" 
   
*/

 



answered Apr 7, 2022 by avibootz

Related questions

1 answer 173 views
1 answer 142 views
1 answer 183 views
1 answer 143 views
1 answer 158 views
1 answer 166 views
1 answer 82 views
...