javascript

Get current year using Javascript Date getFullYear() method

To get the current year using javascript, you can use the .getFullYear() method of Date.

const today_date = new Date();
const current_year = today_date.getFullYear();
// -> returns the current year

In the above code snippet, we are getting current year from today's date. For this we are creating javascript Date object first and then using method getFullYear() to get the current date.

Live Demo

Was this helpful?