Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.getDate

Returns the day of the month.

Available since: ES1

Syntax

date.getDate()

Return value

numberThe day of the month from 1 to 31.

Examples

The day of the month:

console.log(new Date(2026, 2, 15).getDate());

Output:

15

The number of days in a month — day zero of the next month:

const daysInFebruary = new Date(2028, 2, 0).getDate();
 
console.log(daysInFebruary);

Output:

29

Notes

Do not confuse it with getDay(): that one returns the day of the week.

See also

Related recipes

In the tutorial

  • Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.

Thanks for reading!

Donate to the site — we work hard for you.