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 140 views
1 answer 115 views
1 answer 144 views
1 answer 184 views
1 answer 150 views
1 answer 151 views
151 views asked May 1, 2022 by avibootz
1 answer 143 views
...