getDay()
ES1+Returns the day of the week for the given date according to local time, as an integer from 0 (Sunday) to 6 (Saturday). The value indexes weekday-name arrays directly, but note that it differs from ISO 8601 numbering, where Monday is 1 and Sunday is 7.
Syntax
date.getDay()Return Value
A number (0-6) representing the day of the week (0 = Sunday)
Examples
const date = new Date('2024-01-15'); // 월요일
const days = ['일', '월', '화', '수', '목', '금', '토'];
console.log(date.getDay());
console.log(days[date.getDay()] + '요일'); 📌 When to Use
Use getDay() whenever logic branches on the weekday: skipping weekends in delivery estimates and SLA timers, highlighting Saturdays and Sundays in a calendar, scheduling jobs that run only on business days, aligning a calendar grid (how many blank cells precede the 1st of the month), or computing "next Monday" style targets. It answers the question "which column of the week does this date fall in", which pure day-of-month math cannot. Weekend detection is the archetypal use: day === 0 || day === 6 covers the Western convention, though genuinely international products should remember that the weekend is Friday-Saturday in much of the Middle East and that which day starts the week varies by locale, information available programmatically via Intl.Locale's week info rather than hardcoded assumptions. For display, resist mapping the index through a hand-rolled English array; toLocaleString(locale, { weekday: "long" }) returns correctly localized names. As with all local-time getters, the same instant can be a different weekday in another time zone, so server-side weekday logic that must be region-independent should use getUTCDay() or, better, be computed in the user's explicit IANA time zone.
⚠️ Common Mistakes
Mixing up getDay() and getDate(); the weekday getter has the shorter name. Using getDate() % 7 as a weekday, or getDay() as a calendar-cell number, are both classic and produce plausible-looking wrong output that survives casual testing.
Assuming Monday-based or 1-based numbering as in ISO 8601, Java, or cron conventions. In JavaScript Sunday is 0 and Saturday is 6; a schedule table indexed with Monday=0 shifts every rule by one day, so Friday deployments start firing on Saturdays.
Hardcoding the week's start as Sunday (or Monday) in calendar UIs. Locales differ: the US starts weeks on Sunday, most of Europe on Monday, several Middle Eastern locales on Saturday. Use (getDay() + 7 - weekStart) % 7 with a locale-derived weekStart.
The date-only parsing trap again: new Date("2024-03-10") is UTC midnight, so getDay() reports the previous weekday for users west of Greenwich. A weekly report that keys off the weekday of an ISO date string will bucket Sunday data into Saturday for American users.
Computing "next Friday" with a loop that mutates the original Date, or with modular arithmetic that returns today when today already is Friday but the requirement was the following week. Decide explicitly whether the current day counts, and operate on a clone.
✅ Best Practices
Encapsulate weekend and business-day rules in named helpers (isWeekend, isBusinessDay) so the day-number convention lives in one place, can honor regional weekend definitions, and can later incorporate a holiday calendar without touching call sites.
Jump to a target weekday arithmetically instead of looping: const delta = (target - d.getDay() + 7) % 7; clone.setDate(d.getDate() + (delta || 7)) yields the next occurrence, with the || 7 controlling whether "today" qualifies.
Use toLocaleString(locale, { weekday: "long" }) or a cached Intl.DateTimeFormat for weekday names; localized names also handle scripts and abbreviation conventions ("Tue", "화", "Di") that hand-rolled arrays get wrong.
For calendar grids, compute the leading offset from the first of the month: new Date(y, m, 1).getDay(), adjusted for the locale's first day of week, gives the number of empty leading cells; the same formula transposes any date into its grid position.
Real business-day systems need more than weekend skipping: public holidays vary by country and year. Keep a holiday set alongside the weekday check, and for complex recurrence rules consider Temporal (dayOfWeek is ISO 1-7, removing the Sunday-zero trap) or an RRULE library.
⚡ Performance Notes
getDay() is a constant-time read of the cached local-time fields, so the getter itself never matters for performance. What can matter is the shape of algorithms built on it. Day-by-day loops, as in business-day counters, cost one setDate() normalization per day; that is perfectly fine for spans of weeks or months, but for multi-year ranges compute full weeks arithmetically (each week contributes a fixed number of business days) and loop only over the remainder, turning O(days) into O(1) plus a tiny tail. When labeling weekdays for many dates, hoist a single Intl.DateTimeFormat with { weekday: "long" } outside the loop; constructing the formatter per date is orders of magnitude more expensive than format() calls against a cached instance and dominates any calendar-rendering profile.
🌍 Real World Example
Business Days Calculator
Delivery estimates, SLA clocks, and HR workflows all need "N business days from now", and this example shows the standard loop: advance one calendar day at a time with setDate(), counting only days whose getDay() is neither Saturday nor Sunday. Working through the calendar rather than adding raw milliseconds keeps the result correct across daylight saving changes and month boundaries. In production the weekday test typically grows a holiday-calendar lookup, but the skeleton stays the same; the function also reports the resulting weekday name for human-friendly confirmation messages.
function addBusinessDays(startDate, daysToAdd) {
const result = new Date(startDate);
let addedDays = 0;
while (addedDays < daysToAdd) {
result.setDate(result.getDate() + 1);
const dayOfWeek = result.getDay();
// Skip weekends (0 = Sunday, 6 = Saturday)
if (dayOfWeek !== 0 && dayOfWeek !== 6) {
addedDays++;
}
}
return {
deliveryDate: result.toLocaleDateString(),
dayOfWeek: result.toLocaleString('en-US', { weekday: 'long' }),
businessDays: daysToAdd
};
}
console.log(addBusinessDays('2024-03-15', 5)); // Friday + 5 business days
// { deliveryDate: '3/22/2024', dayOfWeek: 'Friday', businessDays: 5 }