JavaScript setUTCFullYear() Method
Example
Set the year to 1992:
var d = new Date();
d.setUTCFullYear(1992);
d Output result:
Try it »
Definition and Usage
The setUTCFullYear() method is used to set the year according to Universal Time (UTC).
**Note:** Coordinated Universal Time, also known as Universal Time, Universal Standard Time, or International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).
**Note:** UTC time is the same as GMT (Greenwich) time.
Browser support





All major browsers support the setUTCFullYear() method.
Syntax
Date
.setUTCFullYear(
year
,
month
,
day
)
Parameter value
| Parameters | Description |
|---|---|
| year | Required. The value to set for the year field of dateObject. |
| This parameter should be a full year including the century, such as 1999, not just an abbreviated year value such as 99. | |
| month | Optional. The value to set for the month field of dateObject. Expressed in universal time.
This parameter is an integer between 0 and 11: |
This parameter is an integer between 1 and 31:
- 0 is the last hour of the previous month.
- -1 is the hour before the last hour of the previous month.
If the current month has 31 days:
- 32 is the first day of the next month.
If the current month has 30 days:
- 32 is the second day of the next month
Return Value
| Type | Description |
|---|---|
| Number | The number of milliseconds from January 1, 1970 to the adjusted date. |
Technical Details
| JavaScript version: | 1.3 |
|---|
More examples
Example 2
Set the date to October 3, 2020:
var d = new Date();
d.setUTCFullYear(2020,10,3);
d Output result:
Try it »
Example
Set the date to 6 months earlier according to Universal Time (UTC):
var d=new Date();
d.setUTCFullYear(d.getUTCFullYear,d.getUTCMonth()-6);
d Output result:
Try it »
JavaScript Date object