Date.prototype.setFullYear() changes the year (and optionally month and day) of a Date according to local time. It mutates the object in place and returns the new epoch milliseconds.
Remember
date.setFullYear(year)
date.setFullYear(year, monthIndex)
date.setFullYear(year, monthIndex, day)
year = full year (e.g. 1995, 0, 2026)
monthIndex = 0–11 (optional; Jan = 0)
day = 1–31 (optional; requires month)
→ mutates date
→ returns new epoch ms (or NaN if invalid)
Syntax
Call date.setFullYear. Start with this line.
JavaScript
date.setFullYear(y[, m[, day]])
Call
What it does
date.setFullYear(y[, m[, day]])
Primary signature.
date.setFullYear(...)
Call with the arguments your case needs.
Built into JavaScript. Call setFullYear(...) on a Date instance — no import required.
Library declarations
JavaScript
date.setFullYear(y[, m[, day]])
Parameters
Parameter
Description
yearValue
Required. Full year to write
monthValue
Optional. Month index 0–11
dateValue
Optional. Day of month; requires monthValue
Return Value
Return Value
Description
*
The value returned by date.setFullYear().
JavaScript Examples
Example 1 — Set the Year
Change only the local year; month and day stay the same.
Change year only. Month/day stay Feb 29 conceptually.
Normalize. 2025 has no Feb 29 → March 1.
Check fields. Year 2025, month 2, day 1.
Compatibility
Browser & Runtime Support
Date.prototype.setFullYear() is part of the language from early ECMAScript and is Baseline Widely available (MDN).
✓ Baseline · Widely available
Date.prototype.setFullYear()
Supported in every modern browser and Node.js. No polyfill needed for ordinary web apps.
99%Modern browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Date.setFullYear()Excellent
Bottom line: Safe everywhere. Focus on leap-day overflow and local vs UTC choice rather than feature detection.
Frequently Asked Questions
It sets the year of a Date in local time. You can also pass optional month (0–11) and day arguments. The Date is mutated in place and the method returns the new epoch milliseconds.
Yes. setFullYear(year, monthIndex, day) updates year, month, and day together. If you pass day, you must also pass month.
getFullYear() reads the local year. setFullYear(year) writes a new year. They are the read/write pair for four-digit years.
JavaScript normalizes overflow. Feb 29, 2024 becomes March 1, 2025 when you call setFullYear(2025) without changing month/day.
No. It returns a number (epoch milliseconds). Do not chain another setter on the return value.
setFullYear() changes the local calendar year. setUTCFullYear() changes the UTC calendar year. Prefer UTC setters for timezone-agnostic logic.