JS Built-ins
← Date37 / 120
DategetDaybeginner

getDay() β€” Sunday is 0

πŸ“– Usage Example
const d = new Date(2024, 0, 15)  // Monday
d.getDay()  // β†’ 1
// 0=Sun, 1=Mon, …, 6=Sat

Use getDay() to retrieve the day of the week (0 = Sunday through 6 = Saturday) in local time.

Date.prototype.getDay()

Sunday has the index 0. Jan 7, 2024 was a Sunday.

Challenge: Verify that new Date(2024, 0, 7).getDay() returns 0.

πŸ’‘ Hints (1)
  • β€’ Sunday = 0, Monday = 1, …, Saturday = 6 in the getDay() system