Sets the year for a specified date according to local time.
Method of Date (deprecated)
Syntax
setYear( yearValue )
Parameters
Parameter | Description |
---|---|
yearValue | An integer. |
Description
setYear is no longer used and has been replaced by the Date.setFullYear method.
If yearValue is a number between 0 and 99 (inclusive), then the year for dateObjectName is set to 1900 + yearValue. Otherwise, the year for dateObjectName is set to yearValue.
To take into account years before and after 2000, you should use Date.setFullYear instead of setYear so that the year is specified in full.
Examples
Note that there are two ways to set years in the 20th century.
Example 1. The year is set to 1996.
Example 2. The year is set to 1996.
Example 3. The year is set to 2000.