The .getDate() method returns the day of the month.



The return value of .getDate() is an integer number between 1 and 31 representing the day of a month.


Suppose there is a need to find out if it is before the 10th of the current month:

const today = new Date('June 22, 2021 10:41:30');
if (today.getDate() < 10) {
console.log('It is before the 10th!');
} else {
console.log('It is the 10th, or later!');
// Output: It is the 10th, or later!

Codebyte Example

The example below is runnable, and assigns the variable myDate to a new given Date, then the result of the .getDate() method is stored in payDay. Finally, a console.log call prints this value to the screen:


All contributors

Looking to contribute?

Learn JavaScript on Codecademy