JavaScript .getMinutes()

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.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours

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.

Code
Output

All contributors

Contribute to Docs

Learn JavaScript on Codecademy

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours