How to use getUTCFullYear in JavaScript

In this article, I will explain use of getUTCFullYear() method in JavaScript date object.
  • 1866

JavaScript date getUTCFullYear() method

  • getUTCFullYear() of date object returns the year of the specified date according to Coordinated Universal Time.

  • In getUTCFullYear() method, The returned value is an absolute number.

  • getUTCFullYear() method returns a four-digit number

Syntax

Date.getUTCFullYear()

Example

In the following example show to how can be used getUTCFullYear() method in javascript.

<!DOCTYPE html>

<html>

<body>

<h3 style="color:ActiveCaption">JavaScript getUTCFullYear() Method Example</h3>

<p id="demo">Click for display the year, according to UTC.</p>

<button onclick="myFunction()">Click On</button>

<script type="text/javascript">

    function myFunction() {

        var d = new Date();

        var x = document.getElementById("demo");

        document.write("According UTC year is: " + d.getUTCFullYear());

    }

</script>

</body>

</html>

Output1

getUTCFullYear 1.jpg

Output2

getUTCFullYear 2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.