JavaScript getUTCMinutes(): Get the UTC Minutes

The JavaScript getUTCMinutes() method is used to get the minutes (0-59) of the UTC date. UTC stands for Universal Time Coordinated, which is the same as Greenwich Mean Time (GMT). For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>
   
   <p id="xyz"></p>

   <script>
      const d = new Date();
      let minutes = d.getUTCMinutes();
      document.getElementById("xyz").innerHTML = minutes;
   </script>

</body>
</html>
Output

In the above example, first a new "Date" object is created by calling:

const d = new Date();

which sets the current date and time.

The getUTCMinutes() function on the "Date" object "d" is then called, which returns the current UTC minute as an integer value between 0 and 59. The result is saved in the variable "minutes."

Finally, the innerHTML property of the HTML element with the ID "xyz" is set to the value of minutes using the

document.getElementById("xyz").innerHTML = minutes;

statement. This updates the contents of the HTML element to display the current UTC minute.

JavaScript getUTCMinutes() syntax

The syntax of the getUTCMinutes() method in JavaScript is:

x.getUTCMinutes()

where x must be an object of the Date() constructor.

The getUTCMinutes() method returns a number from 0 to 59, which will be the minutes of the UTC time.

Advantages of the getUTCMinutes() function in JavaScript

Disadvantages of the getUTCMinutes() function in JavaScript

JavaScript Online Test


« Previous Tutorial Next Tutorial »


Liked this post? Share it!