Date.setYear() (Method)

Sets a non-Y2K compliant year number of the time object.


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 in JavaScript 1.3
Property/method value type:Time value
JavaScript syntax:-myDate.setYear(aYearNumber)
Argument list:aYearNumberIf the year number is less than 100, then 1900 is added to it.

The result returned by this method is the new time value of the containing object having been adjusted by the values passed in as arguments.

The computation is carried out in local time coordinates.

This method has difficulties with properly resolving the century, which is why it is deprecated and should be replaced by Date.setFullYear() 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.


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


ECMA 262 edition 2 - section -

ECMA 262 edition 3 - section - B.2.5