JavaScript Date getDay() method returns the “day of the week(0-6) for this date according to local time, where 0 represents Sunday.”
Syntax
getDay()
Return value
It returns an integer between 0 and 6, representing the day of the week for the given date according to local time: 0 for Sunday and 6 for Saturday. Returns NaN if the date is invalid.
Example 1: Display the day of the week for today
let date = new Date();
let days = ["Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"];
let dayName = days[date.getDay()];
console.log("Today is " + dayName + ".");
Output
Today is Tuesday.
Example 2: Find out which day of the week a specific date was
let specificDate = new Date("July 4, 2022");
let days = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
let dayName = days[specificDate.getDay()];
console.log("July 4, 2022 was a " + dayName + ".");
Output
July 4, 2022 was a Monday.
Example 3: Display the next day of the week
let date = new Date();
let days = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
let nextDayIndex = (date.getDay() + 1) % 7;
let nextDayName = days[nextDayIndex];
console.log("Tomorrow will be " + nextDayName + ".");
Output
Tomorrow will be Wednesday.
Browser Compatibility
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
That’s it!
Related posts
How to Generate Dates Between Two Dates in JavaScript
How to Add Days to Date in JavaScript
How to Compare Two Dates in JavaScript
How to Subtract Days from a Date in JavaScript
How to Format Dates in JavaScript

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.