Search code snippets, questions, articles... Chrome Extension

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
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

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?
0 Comments
Join Devsheet Ask a Question