Sets the year of the Date object using local time.
SyntaxdateObj.setFullYear( numYear [, numMonth [, numDate ]])
The following example illustrates the use of the setFullYear method:
var date1 = new Date("1/1/2001");
date1.setFullYear(2007);
var date2 = new Date("1/1/2001");
date2.setFullYear(2008, 10, 3);
document.write (date1.toLocaleString());
document.write ("<br />");
document.write (date2.toLocaleString());
Remarks
All set methods taking optional arguments use the value returned from corresponding get methods, if you do not specify the optional argument. For example, if the numMonth argument is optional, but not specified, JavaScript uses the value returned from the getMonth method.
In addition, if the value of an argument is greater than its calendar range or is negative, the date rolls forward or backward as appropriate.
To set the year using Universal Coordinated Time (UTC), use the setUTCFullYear method.
The range of years supported in the date object is approximately 285,616 years before and after 1970.
See also Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4