Get the day name from given date in Javascript

You can get the day name from a date using javascript. Below are some code examples that will show you how to get the day name from a date string to a date.

const date_str = "07/20/2021";
const date = new Date(date_str);
const full_day_name = date.toLocaleDateString('default', { weekday: 'long' });
// -> to get full day name e.g. Tuesday

const short_day_name = date.toLocaleDateString('default', { weekday: 'short' });
// -> TO get the short day name e.g. Tue

In the above code snippet, we are using .toLocaleDateString() method of javascript date object. We are passing 'default' as the language code in which we want to access the day name and the weekday key is assigned 'long' or 'short' value.

Live Demo

const days_name = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const date_str = "03/17/2021"; // mm/dd/yyyy
const date_obj = new Date(date_str);
const day_name = days_name[date_obj.getDay()];
In the above code, we have defined days' names in an array. We have a date in string format from which we want to get the day name. First, we convert the date string to the date object and then use the getDay() method. We get the index of day.
var dateStr = '07/16/2019';
var date = new Date(dateStr);

console.log(date.toLocaleDateString("en-US", { weekday: 'long' }));
// -> Tuesday
console.log(date.toLocaleDateString("hi-IN", { weekday: 'long' }));
// -> ???????
console.log(date.toLocaleDateString("de", { weekday: 'long' }));
// -> Dienstag
console.log(date.toLocaleDateString("zh-CN", { weekday: 'long' }));
// -> ???
console.log(date.toLocaleDateString("ar-om", { weekday: 'long' }));
// -> ????????
console.log(date.toLocaleDateString("ru-RU", { weekday: 'long' }));
// -> ???????
console.log(date.toLocaleDateString("ko-KR", { weekday: 'long' }));
// -> ???
Here we are getting day names in different languages. We are using language code to be passed in the .toLocaleDateString() function to get the desired result. Live demo for above code is
Was this helpful?