Javascript Reference - JavaScript getUTCFullYear() Method








getUTCFullYear()
Returns the four-digit year of the UTC date value.

UTC time is the same as GMT time.

Browser Support

getUTCFullYear() Yes Yes Yes Yes Yes

Syntax

dateObject.getUTCFullYear();

Parameters

None.

Return Value

return a number, representing the year (four digits).





Example


var myDate = new Date();
console.log(myDate.getUTCFullYear());

The code above generates the following result.

Example 2

The following code returns the UTC year of a specific date.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--  ww  w.  j  ava2  s.c  om-->
    var d = new Date("July 12, 1976 01:23:00");
    var n = d.getUTCFullYear();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

The code above is rendered as follows: