How to convert seconds to HH:MM:SS in JavaScript

1 Answer

0 votes
const seconds = 4998;

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:
  
"01:23:18"
"01:23:18"
  
*/

 



answered Mar 19, 2022 by avibootz

Related questions

1 answer 148 views
2 answers 162 views
1 answer 150 views
1 answer 151 views
151 views asked May 1, 2022 by avibootz
1 answer 140 views
1 answer 144 views
1 answer 138 views
...