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

1 Answer

0 votes
const milliseconds = 873745347;

const hhmmss = Math.floor(milliseconds / (1000 * 60 * 60)) + ":" + 
               Math.floor(milliseconds / (1000 * 60)) % 60 + ":" +
               Math.floor(milliseconds / 1000) % 60;

console.log(hhmmss);
  
  
  
  
/*
run:
  
"242:42:25"
  
*/

 



answered Apr 7, 2022 by avibootz

Related questions

1 answer 143 views
1 answer 141 views
1 answer 86 views
1 answer 146 views
1 answer 136 views
2 answers 158 views
2 answers 232 views
...