How to get the current date and time in seconds using Node.js

1 Answer

0 votes
const currentDate = new Date();

const seconds = Math.floor(currentDate.getTime() / 1000);

console.log(seconds);

  
  
  
  
/*
run:
  
1646387816

*/

 



answered Mar 4, 2022 by avibootz

Related questions

1 answer 255 views
1 answer 281 views
5 answers 664 views
1 answer 213 views
...