How to add years to a date in TypeScript

1 Answer

0 votes
const date = new Date('2022-05-11');

date.setFullYear(date.getFullYear() + 1);

console.log(date.toDateString()); 


  
  
  
  
/*
run:
  
"Thu May 11 2023" 
  
*/

 



answered Mar 22, 2022 by avibootz
...