English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
setUTCFullYear()Set the year in the Date object according to world time (four-digit number).
This method can also be used to set month and month.
If the specified parameters are out of the expected range, thensetUTCFullYear() willTry to update other parameters and the date information in the Date object accordingly.
For example, if you setmonth(month)value specification16 ,then the year will increase1(year value+ 1),while the month will use4.
World Standard Time (UTC) is the time standard set for world time.
date.setUTCFullYear(year, month, day)
var d = new Date(); d.setUTCFullYear(2010);Test and See‹/›
If not specifiedmonthanddayIf the month parameter is not specified, then use the values returned by the getUTCMonth() and getUTCDate() methods.
All browsers fully support the setUTCFullYear() method:
Method | |||||
setUTCFullYear() | is | is | is | is | is |
Parameter | Description |
---|---|
year | (Required) an integer specifying the numeric value of the year, for example1992 |
month | (Optional) an integer between11an integer between, representing January to December |
day | (Optional) an integer between1to31an integer between, representing the day of the month. Note:If specifieddayIf the month parameter is specified, then you must also specifymonthParameters. |
Return Value: | 1970 years1Month1Milliseconds between 00:00:00 UTC of the day and the update date |
---|---|
JavaScript Version: | ECMAScript 1 |
Specify16As the month value:
var d = new Date(); d.setUTCFullYear(2010, 16);Test and See‹/›