getDay() returns the weekday for a JavaScript Date in local time: 0 for Sunday through 6 for Saturday.
const date = new Date(2026, 8, 10);
console.log(date.getDay()); // 4 (Thursday)
Use getDate() instead when you need the numbered day within the month.
const weekday = date.getDay();
The returned values are Sunday 0, Monday 1, Tuesday 2, Wednesday 3, Thursday 4, Friday 5 and Saturday 6.
const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
const name = weekdays[date.getDay()];
console.log(name);
For user-facing text, locale formatting avoids maintaining your own weekday-name array.
const name = date.toLocaleDateString("en-US", { weekday: "long" });
console.log(name);
const day = date.getDay();
const isWeekend = day === 0 || day === 6;
Weekend definitions vary by region and business rules, so do not hardcode Saturday/Sunday when your application serves a different calendar convention.
const localWeekday = date.getDay();
const utcWeekday = date.getUTCDay();
The two can differ when local time and UTC fall on different calendar days.
Weekday numbers are useful for recurring calendar rules. See the second Saturday example and the weekday project.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| balaji | 04-03-2013 |
| hai, i need that, if i give my date of birth in recent year like(12/12/2012) then i get the day of the date inwhich year i born.......... | |
| smo | 09-04-2013 |
| This part is added now. Link is there at the end of this tutorial. | |