JavaScript getUTCFullYear

The JavaScript getUTCFullYear function returns the 4-digit year number from a given date according to Coordinated Universal Time (UTC).

The syntax of the getUTCFullYear function is:

 Date.getUTCFullYear()

Return Value: The getUTCFulYear method does not accept a parameter value and returns an integer representing the year number (yyyy) from a date.

JavaScript getUTCFullYear example

In this example, we use the getUTCFulYear function to return the year from the current date and time.

const dt = new Date();
let y = dt.getUTCFullYear();
console.log(y);
console.log(dt);
2026 
Fri Jun 12 2026 20:38:15 GMT-1000 (Hawaii-Aleutian Standard Time)

Example 2: Get Full Year from custom date

In this JavaScript example, we use the Date() constructor to parse the custom string date. Next, we use the getUTCFullYear() method to display the UTC full year from the custom date.

const dt = new Date("April 1, 2016 10:14:22");
console.log(dt.getUTCFullYear());
console.log(dt);
2016 
Fri Apr 01 2016 10:14:22 GMT-1000 (Hawaii-Aleutian Standard Time)

Example 3: In this JavaScript getUTCFullYear example, we display the Year from the custom date without the year. This example returns the default year (2001) as the output.

const dt = new Date("April 1 10:14:22");
console.log(dt.getUTCFullYear());
console.log(dt);
2001 
Sun Apr 01 2001 10:14:22 GMT-1000 (Hawaii-Aleutian Standard Time)

Example 4: getUTCFullYear returns NaN

The getUTCFullYear() method works only on valid dates, and if we pass invalid dates, it returns NaN. Here, we parse a string date with a month number 18, which is invalid. So, it returns NaN.

const dt = new Date("2025-18-01");
console.log(dt.getUTCFullYear());
console.log(dt);
NaN 
Invalid Date

What is the difference between getFullYear() and getUTCFullYear() in JavaScript?

Both getFullYear() and getUTCFullYear() are date functions that return the four-digit year part from the given date.

  • getFullYear(): It returns the year of the given date according to the local system time zone.
  • getUTCFullYear(): It returns the year of the given date according to the Universal Coordinated Time (UTC) zone.  

The following example shows the difference. Here, we used January 1st, 2026, as the custom date. The getUTCFullYear() extracts the year from the given date. However, the getFullYear() considers the local system time zone, which we set to Hawaii. So, it returns 2025.

const dt = new Date("2026-01-01");
console.log(dt.getUTCFullYear());
console.log(dt.getFullYear());
console.log(dt);
2026 
2025 
Wed Dec 31 2025 14:00:00 GMT-1000 (Hawaii-Aleutian Standard Time)