How to get the current time in TypeScript

1 Answer

0 votes
let currentDate : Date = new Date();
 
let currentTime : string = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds();
 
console.log(currentTime);
 
     
     
     
     
/*
run:
 
"20:26:50" 
     
*/

 



answered Nov 7, 2022 by avibootz

Related questions

...