JavaScript setUTCFullYear()Method
Example
Set the year to 1992:
var d = new Date();
d.setUTCFullYear(1992);
d.setUTCFullYear(1992);
dOutput:
Try it yourself »
Definition and Usage
The setUTCFullYear() method sets the year according to universal time (UTC).
Tip:Coordinated Universal Time, also known as World Unified Time, World Standard Time, International Coordinated Time, abbreviated as UTC ( Universal Coordinated Time).
Tip:UTC time is GMT (Greenwich) time.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the setUTCFullYear() method.
Syntax
Date.setUTCFullYear(year,month,day)
Parameter Values
| Parameter | Description |
|---|---|
| year | Required. The value of the year field to be set for the dateObject. This parameter should be a complete year including the century value, such as 1999, not just an abbreviated year value, like 99. |
| month | Optional. The value of the month field to be set for the dateObject. Expressed in universal time. This parameter is an integer between 0 and 11:
|
| day | Optional. The value of the day field to be set for the dateObject. Expressed in universal time. This parameter is an integer between 1 and 31:
If the current month has 31 days:
If the current month has 30 days:
|
Return Value
| Type | Description |
|---|---|
| Number | The number of milliseconds between January 1, 1970 and 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.setUTCFullYear(2020,10,3);
dOutput:
Try it yourself »
Example
Set the date to 6 months ago according to universal time (UTC):
var d=new Date();
d.setUTCFullYear(d.getUTCFullYear,d.getUTCMonth()-6);
d.setUTCFullYear(d.getUTCFullYear,d.getUTCMonth()-6);
dOutput:
Try it yourself »
Other Extensions
JavaScript Date Object