How to get the current year in JavaScript?

To get the current year, use the getFullYear() JavaScript method. JavaScript date getFullYear() method returns the year of the specified date according to local time. The value returned by getFullYear() is an absolute number. For dates between the years 1000 and 9999, getFullYear() returns a four-digit number, for example, 2008.


You can try to run the following code to get the current year −

Live Demo

      <title>JavaScript getFullYear Method</title>
         var dt = new Date("December 30, 2017 21:25:10");
         document.write("getFullYear() : " + dt.getFullYear() );


getFullYear() : 2017