How to convert seconds to HH:MM:SS in Node.js

1 Answer

0 votes
const seconds = 7201;

const hhmmss = new Date(seconds * 1000).toISOString().slice(11, 19);
console.log(hhmmss); 

const hhmmss_ = new Date(seconds * 1000).toISOString().substr(11, 8);
console.log(hhmmss_); 




  
  
/*
run:
  
02:00:01
02:00:01
  
*/

 



answered Mar 19, 2022 by avibootz

Related questions

1 answer 241 views
1 answer 213 views
1 answer 236 views
1 answer 287 views
1 answer 227 views
1 answer 234 views
234 views asked May 1, 2022 by avibootz
1 answer 222 views
...