How to use UTC in Javascript

In this article I am going to explain about UTC() method in Javascript.
  • 1685

JavaScript UTC() Method

UTC stand for Universal Coordinated Time. JavaScript UTC() method use for find number of millisecond between defined Date and midnight 1 January 1970 according to universals time.

Syntax

Date.UTC()

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var dd = Date.UTC(2012, 08, 07);

            var mm = document.getElementById("tst");

            mm.innerHTML = dd;

        }

    </script>

</head>

<body>

    <p>

        click button to find milisecond between specefied date and 1 january 1970</p>

    <h3 id="tst" style="color: Red">

    </h3>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

 UTC.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
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.