setFullYear() writes the four-digit year on a Date object in local time, with optional month and day overload. This guide covers syntax, increment patterns, leap-year normalization, and comparisons with UTC setters.
01
Syntax
setFullYear(y)
02
Overload
y, m, d
03
Mutates
In place
04
+ 1 year
getFullYear
05
Leap day
Normalizes
06
Returns
Epoch ms
Fundamentals
Introduction
Renewals, birthdays, and fiscal rollovers often need to bump a date by one year or snap to a specific calendar day. After reading the year with getFullYear(), setFullYear() is the local-time setter that writes it back.
Like other Date setters, it mutates the original object. Clone with new Date(date) when you must keep the previous instant.
Concept
Understanding the setFullYear() Method
Date.prototype.setFullYear(year [, monthIndex [, day]]) accepts a four-digit year and optional zero-based month and day. When you pass only the year, month and day stay the same—unless normalization is required (for example Feb 29 in a non-leap year).
The method returns epoch milliseconds, not the Date object. Call each setter on the same Date variable when you need multiple changes—do not chain on the numeric return value.
💡
Beginner Tip
To add one year: date.setFullYear(date.getFullYear() + 1). For a full calendar date in one call: date.setFullYear(2027, 6, 15) sets July 15, 2027.
Read the current year, add one, write it back. Watch leap-day dates—Feb 29 plus one year normalizes in non-leap years.
Example 4 — Use the Return Value (Epoch Milliseconds)
setFullYear returns the updated timestamp—not the Date for chaining.
JavaScript
const date = new Date(2026, 1, 26);
const ms = date.setFullYear(2027);
console.log("Returned ms:", typeof ms); // "number"
console.log("Matches getTime():", ms === date.getTime()); // true
// Correct multi-step updates on the same Date:
date.setFullYear(2028);
date.setMonth(11);
date.setDate(31);
There is no Feb 29 in 2025, so the engine normalizes to March 1. Plan birthday and anniversary logic accordingly.
Applications
🚀 Common Use Cases
Subscription renewals — bump expiry by one year.
Date pickers — apply user-selected year to an existing Date.
Fiscal year rollovers — set year while keeping month/day anchors.
Form assembly — combine year, month, day with the three-arg overload.
Historical dates — set years before 1000 or after 9999 (four-digit API).
Clone + mutate — copy a Date before changing the year for comparisons.
🧠 How setFullYear() Updates the Calendar Year
1
Read local parts
Engine loads current local year, month, and day.
Local
2
Apply new year
Year argument replaces the year; optional month/day override too.
setFullYear
3
Normalize
Invalid combos (e.g. Feb 29 in non-leap) roll forward.
Normalize
4
📅
Mutate & return ms
Date updates in place; epoch milliseconds are returned.
Important
📝 Notes
setFullYear() mutates the original Date—clone if you need the old value.
Month argument is zero-based (January = 0), same as getMonth().
Returns epoch ms, not the Date—no fluent chaining on the return value.
Feb 29 in non-leap years normalizes to March 1 (or similar overflow).
Use setUTCFullYear when rules follow UTC, not local time.
Validate with Number.isNaN(date.getTime()) before calling setters on parsed dates.
Compatibility
Browser & Runtime Support
Date.prototype.setFullYear() has been available since ES1. It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.setFullYear()
Supported in Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions. No polyfill required.
99%Universal API
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. Remember the optional month/day overload and that the return value is a number.
Wrap Up
Conclusion
setFullYear() writes the four-digit local year on a JavaScript Date, with an optional month-and-day overload. Use it for renewals and calendar edits; clone first when preserving the original instant.
Next, learn setMonth() to change the month index, or review getFullYear() for reading the year component.