getFullYear() method returns the year of the specified date according to local time.
Use this method instead of the
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
A number corresponding to the year of the given date, according to local time.
The value returned by
getFullYear() is an absolute number. For dates between the years 1000 and 9999,
getFullYear() returns a four-digit number, for example, 1995. Use this function to make sure a year is compliant with years after 2000.
The following example assigns the four-digit value of the current year to the variable
var today = new Date(); var year = today.getFullYear();
|ECMAScript Latest Draft (ECMA-262)
The definition of 'Date.prototype.getFullYear' in that specification.
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
|Chrome Full support 1||Edge Full support 12||Firefox Full support 1||IE Full support 4||Opera Full support Yes||Safari Full support 1||WebView Android Full support 1||Chrome Android Full support 18||Firefox Android Full support 4||Opera Android Full support Yes||Safari iOS Full support 1||Samsung Internet Android Full support 1.0||nodejs Full support Yes|
- Full support
- Full support