Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript getFullYear() Method

JavaScript getFullYear() Method

Date Object Reference JavaScript Date object

Example

Return a year:

var d = new Date();

var n = d.getFullYear();

nOutput result:

Try it »


Definition and Usage

The getFullYear() method returns a 4-digit number representing the year.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getFullYear() method.


Syntax

Date

.getFullYear()

Return Value

Type Description
Number A 4-digit number representing the year.

Technical Details

JavaScript version: 1.3

More examples

Example

Return the year of a specified date:

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

var n = d.getFullYear();

n Output result:

1983

Try it »


Date Object Reference JavaScript Date object