Get Current Year in JavaScript

This tutorial teaches how to get the current year in JavaScript.

Use Date() Object

Date is a built-in object to handle all the date-time related operations. We can get the current year using the getFullYear() method attached to it. getFullYear() method returns the year of the current date according to local time. It returns a four-digit number between 1000 and 9999. It returns an absolute number.

var currentTime = new Date();
var year = currentTime.getFullYear()
console.log(year);

Output:

2021
Contribute
DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - JavaScript DateTime

  • Get Current Time in JavaScript