Date.getYear()

JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE 3+, Opera3+ Syntax

							date.getYear()

Description

The getYear() method returns the year portion of the Date object. Unfortunately, the year is represented as either a two-digit number or a four-digit number, depending on the browser version. For example, the year 1983 may be returned from the methods as 1983 or just 83. The getYear() method was depreciated in JavaScript 1.2 in favor of the getFullYear() method.

Caution

Netscape version 2 and 3 display the years from 1900 to 1999 by subtracting 1900 from the year to effectively create a two-digit representation of the year. Years less than 1900 and greater than 1999 are displayed as four-digit numbers.

Netscape version ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.