.getMinutes()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Jun 22, 2021Updated Jun 5, 2023
Contribute to Docs

Called from an instance of the Date class, will return the minutes according to the local time.

Syntax

myDate.getMinutes();

The return value of getMinutes() will only be an integer number between 0 and 59, meaning the minutes according to the local time.

Example

To determine if it has been 15 minutes:

const today = new Date('June 25, 2021 13:15:00');
if (today.getMinutes() >= 15) {
console.log('Hurry up, it has been 15 minutes!');
} else {
console.log('Take your time, we still have time for it.');
}
// Output: Hurry up, it has been 15 minutes!

Codebyte Example

The example below defines a new Date object dateTimeNow, and stores the result of the getMinutes() method in a new variable minutes. Finally, the current date\time, minutes, and the minutes remaining in the hour are all logged to the console.

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn JavaScript on Codecademy