JavaScript Date.prototype.getFullYear() Method
The getFullYear() method returns the year of a date, as a four-digit number, in local time.
Description
The getFullYear() method returns the year of the date according to local time. Use it instead of the old getYear(), which returns the year minus 1900. getUTCFullYear() returns the year in UTC.
Like the other get...() methods without "UTC" in their name, it uses the time zone of the user's device, so the same moment can give different results for users in different places. Each has a getUTC...() counterpart for UTC, and for showing a date in a particular time zone, toLocaleString() with the timeZone option is the easiest approach.
It returns NaN for an invalid date. Comparing years alone is a simple way to check things like whether a date falls in the current year, or to calculate an approximate age.
Syntax
date.getFullYear()Return Value
The four-digit year in local time.
Example
Browser Support
The following information will show you the current browser support for the Date.prototype.getFullYear() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





