JavaScript getDay()

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.

getDay() Syntax and Weekday Numbers Top ↑

const weekday = date.getDay();

The returned values are Sunday 0, Monday 1, Tuesday 2, Wednesday 3, Thursday 4, Friday 5 and Saturday 6.

Convert getDay() to a Weekday Name Top ↑

const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
const name = weekdays[date.getDay()];
console.log(name);

Locale-Aware Weekday Names Top ↑

For user-facing text, locale formatting avoids maintaining your own weekday-name array.

const name = date.toLocaleDateString("en-US", { weekday: "long" });
console.log(name);

Check Whether a Date Is a Weekend Top ↑

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.

getDay() vs getUTCDay() Top ↑

const localWeekday = date.getDay();
const utcWeekday = date.getUTCDay();

The two can differ when local time and UTC fall on different calendar days.

Using getDay() in Calendar Projects Top ↑

Weekday numbers are useful for recurring calendar rules. See the second Saturday example and the weekday project.

Common getDay() Mistakes Top ↑

  • Expecting 1–7 instead of 0–6.
  • Confusing weekday with the day of the month.
  • Assuming every region defines weekends the same way.
  • Ignoring UTC/local differences close to midnight.

getDate() Date Reference




Subscribe to our YouTube Channel here



plus2net.com







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.



We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer