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,
- We create a new Date object
daterepresenting January 15, 2021, at 15:30 UTC. - We use the
getUTCMinutes()method to get the minutes fromdate. - The minutes are stored in the variable
utcMinutes. - We log
utcMinutesto the console usingconsole.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,
- We create a new Date object
nowrepresenting the current date and time. - We use the
getUTCMinutes()method to get the current minutes fromnow. - The current minutes are stored in the variable
currentUTCMinutes. - We log
currentUTCMinutesto the console usingconsole.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,
- We create a new Date object
pastDaterepresenting July 4, 1776, at 12:15 UTC. - We use the
getUTCMinutes()method to get the minutes frompastDate. - The minutes are stored in the variable
pastUTCMinutes. - We log
pastUTCMinutesto the console usingconsole.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.