JS Built-ins
← Date33 / 120
DategetDatebeginner

getDate() β€” last day of January (31)

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

January has 31 days. getDate() for Jan 31 returns 31.

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

πŸ’‘ Hints (1)
  • β€’ January has 31 days; getDate() ranges from 1 to the last day of the month