JavaScript Date.prototype.setFullYear() Method
The setFullYear() method changes the year of a date, and optionally its month and day.
Description
The setFullYear() method sets the year of the date in local time, and optionally the month and day too. Other setters such as setMonth(), setHours() and setMinutes() work in the same way and also roll over out-of-range values.
When you set the year alone, the month and day stay the same, which can roll over: setting the year of 29 February 2028 to 2027 gives 1 March 2027, since 2027 has no 29 February. Passing the month and day at the same time avoids surprises.
It changes the date object in place and returns the new timestamp. Copy the date first if you need to keep the original, and use setUTCFullYear() to work in UTC.
Syntax
date.setFullYear(year)
date.setFullYear(year, monthIndex, day)Parameters
- yearThe four-digit year.
- monthIndexOptional. The month, from 0 to 11.
- dayOptional. The day of the month.
Return Value
The new timestamp of the date, in milliseconds.
Example
Browser Support
The following information will show you the current browser support for the Date.prototype.setFullYear() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





