JavaScript Date setUTCFullYear() Method
- Previous Page setUTCDate()
- Next Page setUTCHours()
- Go Back to the Previous Level JavaScript Date Reference Manual
Definition and Usage
setUTCFullYear()
The method sets the year of the date object according to UTC time (a four-digit number between 1000 and 9999).
Tip:Coordinated Universal Time (UTC) is the time set by the world time standard.
Note:UTC time is the same as GMT time (Greenwich Mean Time).
Instance
Example 1
Set the year to 1992:
var d = new Date(); d.setUTCFullYear(1992);
Example 2
Set the date to November 3, 2020:
var d = new Date(); d.setUTCFullYear(2020, 10, 3);
Example 3
Set the date to six months ago, in UTC time:
var d = new Date(); d.setUTCFullYear(d.getUTCFullYear, d.getUTCMonth() - 6);
Syntax
Date.setUTCFullYear(year, month, day)
Parameter Value
Parameter | Description |
---|---|
year | Required. The value representing the year, allowing negative values. |
month |
Optional. An integer representing the month. Expected value is 0-11, but other values are allowed:
|
day |
Required. An integer representing the day of the month. Expected value is 1-31, but other values are allowed:
If a month has 31 days:
If a month has 30 days:
|
Technical Details
Return Value: | Numeric value, date object, and the milliseconds between midnight on January 1, 1970. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
setUTCFullYear() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Date
Tutorial:JavaScript Date Format
Tutorial:JavaScript Date Setting Methods
- Previous Page setUTCDate()
- Next Page setUTCHours()
- Go Back to the Previous Level JavaScript Date Reference Manual