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 133 views
1 answer 106 views
1 answer 138 views
1 answer 177 views
1 answer 142 views
1 answer 148 views
148 views asked May 1, 2022 by avibootz
1 answer 134 views
...