English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
ThesetFullYear()Method, sets the full year (four-digit year is four digits) for the specified date object based on local time.
This method can also be used to set the month and day of the month.
If the specified parameters are out of the expected range, thensetFullYear()Try to update other parameters and date information in the Date object accordingly.
For example, if you setmonthvalue specification16 ,then the year will increase1(The year value+ 1),while the month will use4.
date.setFullYear(year, month, day)
var d = new Date(); d.setFullYear(2010);Test and see‹/›
If not specifiedmonthanddayThe parameter, if specified, uses the values returned by the getMonth() and getDate() methods.
All browsers fully support the setFullYear() method:
Method | |||||
setFullYear() | is | is | is | is | is |
Parameter | Description |
---|---|
year | (Required) an integer specifying the numeric value of the year, for example1992 |
month | (Optional) 0 to11representing January to December |
day | (Optional) integer between1to31integer between, representing the day of the month. Note:If specifieddayParameter, then you must also specifymonthParameter. |
Return Value: | 1970 years1Month1Milliseconds between the date and time 00:00:00 UTC and the update date |
---|---|
JavaScript Version: | ECMAScript 1 |
Specify16as the month value:
var d = new Date(); d.setFullYear(2010, 16);Test and see‹/›
TheCall setFullYear()The method can choose to set the month and date:
var d = new Date(); d.setFullYear(2010, 8, 30);Test and see‹/›