Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.getFullYear

Returns the year.

Available since: ES1

Syntax

date.getFullYear()

Return value

numberThe four-digit year in local time.

Examples

The year of a date:

console.log(new Date(2026, 2, 15).getFullYear());

Output:

2026

Age from a birth year:

const birth = new Date(1990, 6, 1);
const today = new Date(2026, 2, 15);
 
console.log(today.getFullYear() - birth.getFullYear());

Output:

36

Notes

Do not use the legacy getYear(): it returns the year minus 1900. For UTC time there is the paired getUTCFullYear().

See also

Related recipes

In the tutorial

  • Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.

Thanks for reading!

Donate to the site — we work hard for you.