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:
2026Age 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:
36Notes
Do not use the legacy getYear(): it returns the year minus 1900. For UTC time there is the paired getUTCFullYear().
See also
- Date.prototype.getMonth — Returns the month — a number from 0 to 11.
- Date.prototype.getDate — Returns the day of the month.
- Date.prototype.setFullYear — Sets the year, and optionally the month and day.
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.