Hello Friends 👋,

Welcome To Infinitbility! ❤️

To get the current year in typescript has the new Date().getFullYear() method which will return every time the current year in number datatype.

we have to just call new Date().getFullYear() and it will check the current date and return the current year based on the date.

let year: number = new Date().getFullYear();
console.log(year); // 2022

Now, we know how to get the current year in typescript and the way to hold in a variable.

TypeScript has a new Date() object which is similar to javascript and the date object provides the getFullYear() method which will return the year store in the new date object.

Thanks for reading…