JavaScript > Date

GetUTCMinutes() Method in JavaScript

How to return the minutes, according to UTC in JavaScript?

By using getUTCMinutes() method we can return the minutes, according to UTC.

<p>Click the below button to return the Minutes as per the UTC.</p>
<input type="button" value="Click" onclick="myDate()" />
<p id="myId"></p>

    function myDate() {
        var a = new Date();
        var r = a.getUTCMinutes();
        document.getElementById("myId").innerHTML = r;

In the above code snippet we have given Id as "myId"to the second <p> element in the HTML code. There is a function myDate() in the<script>block which is connected to the Onclick of the HTML button. 

The document.getElementById("myId")returns the element that has Id"id=myID" in the HTML page. We need to return the minutes as per the UTC, for that we are using getUTCMinutes(). Onclick of the button "Click" in th HTML code fires the function myDate() in the <script> block at the same time getUTCMinutes() return the minutes as output according to UTC.


 Views: 3164 | Post Order: 114

Write for us

Hosting Recommendations