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
0 Comments