Javascript - Date getUTCFullYear() Method

The getUTCFullYear() method returns the year as four digits for dates between year 1000 and 9999 of the date object, according to universal time.

Description

The getUTCFullYear() method returns the year as four digits for dates between year 1000 and 9999 of the date object, according to universal time.

UTC time is the same as GMT time.

Syntax

Date.getUTCFullYear()

Parameters

None

Return

A Number, representing the year

Example

Return the year, according to universal time:

Demo

//display the year, according to UTC.

var d = new Date();
var n = d.getUTCFullYear();
console.log(n);/*from   w ww .  ja v  a 2  s.co  m*/


//Return the UTC year of a specific date:

//display the year of a specific date, according to UTC.

var d = new Date("July 21, 2010 01:15:00");
var n = d.getUTCFullYear();
console.log(n);

Result