JavaScript Date getUTCMinutes() Method



In JavaScript, the Date.getUTCMinutes() method is used to retrieve the minutes component of a given date and time in Coordinated Universal Time (UTC). It returns an integer value between 0 and 59, representing the minutes portion of the specified UTC time.

UTC stands for Coordinated Universal Time. It is the primary time standard by which the world regulates clocks and time. UTC is often referred to as "GMT" (Greenwich Mean Time).

Syntax

Following is the syntax of JavaScript Date.getUTCMinutes() method −

getUTCMinutes()

Parameters

This method does not accept any parameters.

Return value

This method returns an integer (between 0 to 59) representing the minutes portion of the specified date and time in UTC. Returns NaN if the date is invalid.

Example 1

In the following example, we are using the JavaScript getUTCMinutes() method to get the minute portion from the date object, according to UTC −

<html>
<body>
<script>
   const date = new Date();
   const minutes = date.getUTCMinutes();
   document.write(minutes);
</script>
</body>
</html>

Output

As we can see in the output below, it retrieved the current UTC minutes.

Example 2

Here, we are creating a custom date object, according to UTC. We then using the getUTCMinutes() method to extract the minutes component −

<html>
<body>
<script>
   const date = new Date('2024-02-08T10:30:00Z');
   const minutes = date.getUTCMinutes();
   document.write(minutes);
</script>
</body>
</html>

Output

If we execute the above program, it returns "30" as minute value.

Example 3

If the Date object is invalid, this mehtod will return "NaN" as result −

<html>
<body>
<script>
   const date = new Date('iunnub');
   const minutes = date.getUTCMinutes();
   document.write(minutes);
</script>
</body>
</html>

Output

As we can see the output, "NaN" is returned.

Advertisements