How to convert milliseconds to hh:mm:ss in Node.js

1 Answer

0 votes
const milliseconds = 873145347;
 
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 106 views
1 answer 133 views
1 answer 129 views
1 answer 177 views
1 answer 140 views
1 answer 148 views
1 answer 79 views
...