JS Built-ins
← Date35 / 120
DategetDatebeginner

getDate() β€” first day via Date constructor

πŸ“– Usage Example
const d = new Date(2024, 0, 15)
d.getDate()  // β†’ 15

Use getDate() to retrieve the day of the month (1–31) in local time from a Date object.

Date.prototype.getDate()

When you pass day 1 explicitly, getDate() returns 1.

Challenge: Verify that new Date(2024, 5, 1).getDate() returns 1 for June 1.

πŸ’‘ Hints (1)
  • β€’ The third argument to the Date constructor is the day-of-month (1-indexed)