JavaScript Date getFullYear() method

Definition and usage

getFullYear() The method returns the year of the specified date (a four-digit number for dates between 1000 and 9999).

Example

Example 1

Return the year:

var d = new Date();
var n = d.getFullYear();

Try it yourself

Example 2

Return the year of a specific date:

var d = new Date("July 21, 1983 01:15:00");
var n = d.getFullYear();

Try it yourself

Syntax

Date.getFullYear()

Parameters

No parameters.

Technical details

Return value: A number representing the year of the specified date.
JavaScript version: ECMAScript 1

Browser support

Method Chrome IE Firefox Safari Opera
getFullYear() Support Support Support Support Support

Related Pages

Tutorial:JavaScript Date

Tutorial:JavaScript Date Format

Tutorial:JavaScript Object Constructor