The setYear()
method sets the year for a specified date according to local time. Because setYear()
does not set full years ("year 2000 problem"), it is no longer used and has been replaced by the setFullYear() method.
dateObj.setYear(yearValue)
yearValue
If yearValue
is a number between 0 and 99 (inclusive), then the year for dateObj
is set to 1900 + yearValue
. Otherwise, the year for dateObj
is set to yearValue
.
setYear()
The first two lines set the year to 1996. The third sets the year to 2000.
var theBigDay = new Date(); theBigDay.setYear(96); theBigDay.setYear(1996); theBigDay.setYear(2000);
Created by Mozilla Contributors, license: CC-BY-SA 2.5