JavaScript getUTCFullYear Function

JavaScript getUTCFullYear function is a Date Function, which returns the year on a given date according to universal time. The syntax of the getUTCFullYear function is:

 Date.getUTCFullYear()

JavaScript getUTCFullYear Function Example

We use the getUTCFulYear to return the year from the current date and time.

<!DOCTYPE html>
<html>
<head>
    <title> JS </title>
</head>
<body>
    <h1> Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt);
  document.write("UTC Full Year : " + dt.getUTCFullYear());
</script>
</body>
</html>
Example

Date and Time: Mon Nov 05 2018 10:52:54 GMT+0530 (Indian Standard Time)
UTC Full Year : 2018

getUTCFullYear Example 2

In this JavaScript example, we are displaying the year from the custom date.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScriptGetUTCFullYearFunction </title>
</head>
<body>
    <h1> JavaScriptgetUTCFullYearFunctionExample </h1>
<script>
  var dt = Date("April 1, 2016 10:14:22");
  document.write("Date and Time : " + dt);
  document.write("UTC Full Year using getUTCFullYear : " + dt.getUTCFullYear());
</script>
</body>
</html>
JavaScript getUTCFullYear Function 2

In this JavaScript getUTCFullYear example, we display the Year from the custom date without the year. This example returns the default year as the output.

<!DOCTYPE html>
<html>
<head>
    <title> JS </title>
</head>
<body>
    <h1> Example </h1>
<script>
  var dt = Date("April 1 10:14:22");
  document.write("DateTime : " + dt);
  document.write("UTC Full Year : " + dt.getUTCFullYear());
</script>
</body>
</html>
Example

DateTime: Sun Apr 01 2001 10:14:22 GMT+0530 (Indian Standard Time)
UTC Full Year : 2001