JS Built-ins
← Date32 / 120
DategetDatebeginner

getDate() β€” first day of month

πŸ“– 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()

The first day of any month is always 1.

Challenge: Verify that new Date(2024, 0, 1).getDate() returns 1.

πŸ’‘ Hints (1)
  • β€’ Day-of-month indexing starts at 1, unlike months which start at 0