VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-date-getfullyear-method/

⇱ JavaScript Date getFullYear() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Date getFullYear() Method

Last Updated : 11 Jul, 2025

The JavaScript Date getFullYear() Method is used to fetch the year from a given Date object.

Syntax:

DateObj.getFullYear()

Parameters:

This function does not accept any parameters.

Return Values:

It returns the year for the given date.

Example 1: This example shows the use of Date getFullYear() Method.

Output:

1996

Example 2: If nothing as a parameter is given to the Date() constructor, then the getFullYear() function returns the current year. 

Output:

2022

Example 3: The date of the month must lie between 1 to 31 because a month cannot have more than 31 days. That is why it returns NaN i.e, not a number because the date for the month does not exist. Hence, the Year will not exist when the date of the month is set as 45 or any number which does not lie between 1 to 31.

Output:

NaN

Example 4: It has applications such as getting the current year. It is used on websites to validate the age of the user. 

Output:

2022

We have a complete list of Javascript Date Objects, to check those please go through this Javascript Date Object Complete referencearticle.

Supported Browsers:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Opera 4 and above
  • Safari 1 and above
Comment