Example 1 — Read the Day of the Month
Call getDate() on a fixed local date (month index is zero-based).
const birthday = new Date(1975, 7, 19); // Aug 19, 1975
console.log(birthday.getDate()); // 19 How It Works
- Build a local date.
new Date(1975, 7, 19)means year 1975, month index7(August), day19. - Read the calendar day.
getDate()returns19— the day-of-month in local time. - Hours are ignored here. Time-of-day does not change this getter’s result for that calendar day.
- No side effects. The
Dateis unchanged;getDateonly reads.

