.getMinutes()
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.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly15 hours