JavaScript Date getUTCMinutes()
Syntax & Examples


Date.getUTCMinutes() method

The getUTCMinutes() method of the Date object in JavaScript returns the minutes (0 – 59) in the specified date according to universal time.


Syntax of Date.getUTCMinutes()

The syntax of Date.getUTCMinutes() method is:

getUTCMinutes()

This getUTCMinutes() method of Date returns the minutes (0 – 59) in the specified date according to universal time.

Return Type

Date.getUTCMinutes() returns value of type Number.



✐ Examples

1 Using getUTCMinutes() to get the UTC minutes of a specific date

In JavaScript, we can use the getUTCMinutes() method to get the minutes from a Date object according to universal time.

For example,

  1. We create a new Date object date representing January 15, 2021, at 15:30 UTC.
  2. We use the getUTCMinutes() method to get the minutes from date.
  3. The minutes are stored in the variable utcMinutes.
  4. We log utcMinutes to the console using console.log() method.

JavaScript Program

const date = new Date('2021-01-15T15:30:00Z');
const utcMinutes = date.getUTCMinutes();
console.log(utcMinutes);

Output

30

2 Using getUTCMinutes() with the current date

In JavaScript, we can use the getUTCMinutes() method to get the current minutes from the current date according to universal time.

For example,

  1. We create a new Date object now representing the current date and time.
  2. We use the getUTCMinutes() method to get the current minutes from now.
  3. The current minutes are stored in the variable currentUTCMinutes.
  4. We log currentUTCMinutes to the console using console.log() method.

JavaScript Program

const now = new Date();
const currentUTCMinutes = now.getUTCMinutes();
console.log(currentUTCMinutes);

Output

45

3 Using getUTCMinutes() with a specific date in the past

In JavaScript, we can use the getUTCMinutes() method to get the minutes from a specific date in the past according to universal time.

For example,

  1. We create a new Date object pastDate representing July 4, 1776, at 12:15 UTC.
  2. We use the getUTCMinutes() method to get the minutes from pastDate.
  3. The minutes are stored in the variable pastUTCMinutes.
  4. We log pastUTCMinutes to the console using console.log() method.

JavaScript Program

const pastDate = new Date('1776-07-04T12:15:00Z');
const pastUTCMinutes = pastDate.getUTCMinutes();
console.log(pastUTCMinutes);

Output

15

Summary

In this JavaScript tutorial, we learned about getUTCMinutes() method of Date: the syntax and few working examples with output and detailed explanation for each example.