JavaScript · More dates

date.setFullYear()

Changes the year, optionally alongside month and day.

Syntax
date.setFullYear(year)

Example

Try it

More in this group

date.getDate() date.getDay() date.getHours() date.getMinutes() date.getMonth() date.getTime() Date.parse() date.setDate()

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course