How to get day, month and year from timestamp in Node.js

1 Answer

0 votes
const timestamp = 1652800307169;

const date = new Date(timestamp);

const year = date.getFullYear();
console.log(year); 

const month = date.getMonth();
console.log(month + 1); 

const day = date.getDate();
console.log(day); 

  
  
  
  
/*
run:
  
2022
5
17
  
*/

 



answered Mar 7, 2022 by avibootz

Related questions

1 answer 148 views
1 answer 171 views
1 answer 129 views
1 answer 180 views
1 answer 145 views
1 answer 138 views
...