How to get day, month and year from timestamp in JavaScript

1 Answer

0 votes
const timestamp = 1632700309168;

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:
  
2021
9
27
  
*/

 



answered Mar 7, 2022 by avibootz

Related questions

1 answer 163 views
1 answer 177 views
1 answer 145 views
1 answer 203 views
1 answer 249 views
1 answer 192 views
...