offline version v3


123 of 264 menu

getFullYear method

The getFullYear method is applied to the date object and returns the year consisting of 4 digits.

Syntax

date.getFullYear();

Example

Let's get the current year:

let date = new Date(); let res = date.getFullYear(); console.log(res); // outputs the current year

Example

In this example, the selected year will be displayed:

let date = new Date(2025, 11, 31); let res = date.getFullYear(); console.log(res);

The code execution result:

2025

See also

  • the getMonth method
    that gets the month
  • the getDate method
    that gets the day of the month
  • the getHours method
    that gets the hours
  • the getMinutes method
    that gets the minutes
  • the getSeconds method
    that gets the seconds
enru