JavaScript Reference ยท Date and Intl
Date.prototype.getFullYear()
Reference for JavaScript getFullYear() and the other Date getters: getMonth, getDate, getDay, getHours and the UTC versions, with zero-based month traps.
getFullYear() returns the four-digit year of a Date, in local time. It belongs to a family of getters that read one part of a date: the month, the day, the hour and so on. Each has a local-time version and a UTC version (getUTCFullYear(), getUTCMonth(), ...).
The most important thing to remember is that the getters differ in how they count: getMonth() starts at 0, getDate() starts at 1, and getDay() is the weekday with 0 for Sunday.
const d = new Date(2026, 2, 15); d.getFullYear(); // 2026 d.getMonth(); // 2 (March) d.getDate(); // 15
Try it
Press Run (or Ctrl + Enter) to see the console output here.
No output.
Press Run (or Ctrl + Enter) to see the console output here.
No output.
Syntax
date.getFullYear() date.getMonth() date.getDate() date.getDay() date.getHours() date.getMinutes() date.getSeconds() date.getMilliseconds()
Parameters: none.
Return value: an integer.
| Method | Range |
|---|---|
getFullYear() |
the four-digit year |
getMonth() |
0 (January) to 11 (December) |
getDate() |
1 to 31 |
getDay() |
0 (Sunday) to 6 (Saturday) |
getHours() |
0 to 23 |
getMinutes(), getSeconds() |
0 to 59 |
getMilliseconds() |
0 to 999 |
For an Invalid Date, every getter returns NaN. Nothing is thrown.
Usage notes
- Local time vs UTC. The plain getters use the time zone of the device. Use the
getUTC...versions when you need results that do not change from computer to computer. getDate()is notgetDay().getDate()is the day of the month;getDay()is the day of the week. Mixing them up is a classic bug.- Add 1 to the month when you show it to people:
getMonth() + 1. - Do not use
getYear(). It is a deprecated method that returns the year minus 1900. - No leading zeros. The getters return numbers, so pad with
String(n).padStart(2, "0")when you build strings. - Date-only ISO strings can shift.
new Date("2026-03-15").getDate()may be 14 west of Greenwich because the string is UTC midnight. UsegetUTCDate()for such values. - Read-only. Getters never modify the date. Use the matching setters to change a part.
- For formatted output such as month names, prefer
toLocaleDateString()over your own lookup table.
Browser support
All of these getters work in every browser and runtime.