Date.getYear() (Method)

Returns a 2 digit non-Y2K compliant year for a date/time.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Deprecated from JavaScript 1.3
Property/method value type:Number primitive
JavaScript syntax:-myDate.getYear()

The result of this method is a 2 digit year number for the date contained in the receiving object.

The year number is a local time value.

However, in this case, the value 1900 is subtracted from the year on the assumption that a two digit year will result.

This can lead to year 2000 problems as the year value may be modulo 100 or it may carry over.

This is why the method is deprecated and should be replaced by Date.getFullYear() in your scripts.

As of ECMA edition 3 it is no longer included in the standard although implementations may still provide it for backwards compatibility.

Warnings:

See also:Date.getFullYear(), Date.prototype, Date.setFullYear(), Date.setYear()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.5

ECMA 262 edition 3 - section - B.2.4