JavaScript Date setUTCFullYear() Method

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);

Try It Yourself

Example 2

Set the date to November 3, 2020:

var d = new Date();
d.setUTCFullYear(2020, 10, 3);

Try It Yourself

Example 3

Set the date to six months ago, in UTC time:

var d = new Date();
d.setUTCFullYear(d.getUTCFullYear, d.getUTCMonth() - 6);

Try It Yourself

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:

  • -1 will lead to the last month of the previous year
  • 12 will lead to the first month of the next year
  • 13 will lead to the second month of the next year
day

Required. An integer representing the day of the month.

Expected value is 1-31, but other values are allowed:

  • 0 will lead to the last day of the previous month
  • -1 will lead to the day before the last day of the previous month

If a month has 31 days:

  • 32 will lead to the first day of the next month

If a month has 30 days:

  • 32 will lead to the second day of the next month

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