Export (0) Print
Expand All

getFullYear Method

Returns the year value in the Date object using local time.

function .getFullYear() : Number

Remarks

To get the year using Coordinated Universal Time (UTC), use the getUTCFullYear method.

The getFullYear method returns the year as an absolute number. For example, the year 1976 is returned as 1976. This avoids the year 2000 problem where dates beginning with January 1, 2000 are confused with those beginning with January 1, 1900.

The following example illustrates the use of the getFullYear method.

function DateDemo(){
   var d, s = "Today's date is: ";
   d = new Date();
   s += (d.getMonth() + 1) + "/";
   s += d.getDate() + "/";
   s += d.getFullYear();
   return(s);
}

Requirements

Version 3

See Also

getUTCFullYear Method | setFullYear Method | setUTCFullYear Method

Applies To: Date Object

Show:
© 2014 Microsoft