JavaScript Date getDate() method returns the “day of the month for this date according to local time.”
Syntax
getDate()
Parameters
This method does not take any parameters.
Return value
The getDate() method returns an integer between 1 and 31, representing the day of the month for the given date according to local time.
Example 1: How to Use the getDate() Method
let today = new Date();
let dayOfMonth = today.getDate();
console.log("Today's date is:", dayOfMonth);
Output
Today's date is: 18
Example 2: Date getDate() returns NaN
let dateobj = new Date("September 32, 1993 05:35:32");
let data = dateobj.getDate();
console.log(data);
Output
NaN
Example 3: Date getDate() returns 1
In JavaScript, the Date object’s getDate() method does not default to returning 1 if the month’s date is not given. Instead, the getDate() method always returns the day of the month for the Date object on which it’s called.
let date2 = new Date(2023, 7);
console.log(date2.getDate());
Output
1
That’s it!
Related posts

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.