Expand Minimize
0 out of 4 rated this helpful - Rate this topic

getFullYear Method (Date) (JavaScript)

JavaScript - Internet Explorer 10

Gets the year, using local time.

dateObj.getFullYear() 

The required dateObj reference is a Date object.

The year as a four-digit number. For example, the year 1976 is returned as 1976. Years specified as two digits in the Date constructor or in setFullYear are assumed to be in the twentieth century, so given "5/14/12", getFullYear returns "1912".

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

The following example illustrates the use of the getFullYear method.

var date = new Date("1/1/01");
document.write(date.getFullYear());

// Output: 1901

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Also supported in Windows Store apps. See Version Information.

Applies To: Date Object (JavaScript)

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.