Javascript - Date getFullYear() Method

The getFullYear() method returns the year as four digits for dates between year 1000 and 9999 from the date object.

Description

The getFullYear() method returns the year as four digits for dates between year 1000 and 9999 from the date object.

Syntax

Date.getFullYear()

Parameters

None

Return

A Number, representing the year of the specified date

Example

Return the year:

Demo

//display the full year of todays date.
var d = new Date();
var n = d.getFullYear();
console.log(n);// w ww  . j  av  a  2 s  . c om

//Return the year of a specific date:
//display the full year of a given date.
var d = new Date("July 21, 2010 01:15:00");
var n = d.getFullYear();
console.log(n);

Result