
The JavaScript getDate() method is a method of the Date object that allows you to retrieve the day of the month of a given date.
This method has no parameters and can be called from any valid Date object.
Here’s an example of the getDate() method in action:
const date = new Date(); // 22nd March 2022 local time
const day = date.getDate();
console.log(day); // 22
The getDate() method will return an integer number between 1 and 31 that represents the day of the month.
You can get the day of the month from a specified date like this:
const date = new Date("January 01, 2010 10:20:20");
const day = date.getDate();
console.log(day); // 1
And that’s how the getDate() method works. 😉