Favorites

JavaScript Date.prototype.setFullYear() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Date.prototype.setFullYear()
JavaScript Date Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

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

const d = new Date(2026, 1, 28);
d.setFullYear(2027);
console.log(d.toDateString());
d.setFullYear(2028, 1, 29);
console.log(d.toDateString());

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.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee