Example 1 — Read the UTC Weekday Index
Build a UTC instant with Date.UTC, then call getUTCDay().
const xmas = new Date(Date.UTC(1995, 11, 25)); // Dec 25, 1995 UTC
console.log(xmas.getUTCDay()); // 1 (Monday) How It Works
- Build a UTC date.
Date.UTC(1995, 11, 25)is December 25, 1995 in UTC (month index11). - Read the weekday.
getUTCDay()returns1— Monday in the 0–6 scale. - Scale reminder.
0= Sunday, so Monday lands at1. - No side effects. The
Dateis unchanged;getUTCDayonly reads.

