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

1 Answer

0 votes
const seconds = 9015;

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:30:15" 
"02:30:15" 
  
*/

 



answered Mar 19, 2022 by avibootz

Related questions

1 answer 221 views
1 answer 265 views
1 answer 214 views
1 answer 259 views
1 answer 223 views
1 answer 231 views
231 views asked May 1, 2022 by avibootz
1 answer 234 views
...