.getMonth()
Anonymous contributors
Anonymous contributors
Anonymous contributors
Published Jun 22, 2021Updated Sep 3, 2021
Contribute to Docs
Called from an instance of the Date
class, will return the month of the year.
Syntax
myDate.getMonth();
The return value of getMonth()
will only be an integer number between 0
and 11
, meaning the month of the year:
0
represents January1
represents February2
represents March- …
10
represents November11
represents December
Example
To determine if it is June or not:
const today = new Date('June 25, 2021 13:41:30');if (today.getMonth() === 5) {console.log('Time flies, it is now June.');} else {console.log('It is not 10 in the morning now.');}// Output: Time flies, it is now June.
All contributors
- Anonymous contributorsAnonymous contributors
- Anonymous contributors
Looking to contribute?
- 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.