JS Built-ins
← Date22 / 120
DategetFullYearbeginner

getFullYear() β€” epoch year is 1970

πŸ“– Usage Example
const d = new Date(2024, 0, 15)
d.getFullYear()  // β†’ 2024

Use getFullYear() to retrieve the four-digit year of a Date object in local time.

Date.prototype.getFullYear()

The Unix epoch (Jan 1 1970 UTC) has a local year of 1970 in most timezones.

Challenge: Verify that new Date(0).getFullYear() returns 1970.

πŸ’‘ Hints (1)
  • β€’ new Date(0) is the Unix epoch β€” January 1, 1970 UTC