JS Built-ins
← Date84 / 120
DatesetFullYearbeginner

setFullYear() β€” set to 1990

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

Use setFullYear() to mutate the year of a Date object in place; the month and day remain unchanged.

Date.prototype.setFullYear()

You can set any valid year, including past years.

Challenge: Verify that after setFullYear(1990), getFullYear() returns 1990.

πŸ’‘ Hints (1)
  • β€’ setFullYear() accepts any integer year, including historical dates