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

1 Answer

0 votes
const timestamp = 1612800307168;

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 
2 
8 
  
*/

 



answered Mar 7, 2022 by avibootz
...