English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript setUTCFullYear() method

 JavaScript Date Object

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.

Syntax:

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.

Browser Compatibility

All browsers fully support the setUTCFullYear() method:

Method
setUTCFullYear()isisisisis

Parameter Value

ParameterDescription
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.

Technical Details

Return Value:1970 years1Month1Milliseconds between 00:00:00 UTC of the day and the update date
JavaScript Version:ECMAScript 1

More Examples

Specify16As the month value:

var d = new Date();
d.setUTCFullYear(2010, 16);
Test and See‹/›

 JavaScript Date Object