To get the current year, you can call the getFullYear() method will return the year of the specified Date according to local time. The value returned by is an absolute number. For the dates between 1000 and 9999 years, the getFullYear() method returns a four-digit number.
Create a new Date() object and invoke getFullYear() method to return the current date:
//Date().getFullYear() let date = new Date().getFullYear(); console.log(date);
Date and Time¶
There is a Date built-in object to handle all the Date and time-related operations. You can use the Date object to display the current Date and time, create a calendar, build a timer, etc. The new operator is used to create a date object.