This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

getFullYear

Summary

Gets the year, using local time.

Syntax

dateObj.getFullYear()

Return Value

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".

Examples

The following example illustrates the use of the getFullYear method.

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

 // Output: 1901

Remarks

The required dateObj reference is a Date object. To get the year using Universal Coordinated Time (UTC), use the getUTCFullYear method.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article