JavaScript Code


JavaScript – Get Day of Week from Date


Date – getDay()

date.getDay()

getDay() returns the day of week, an integer from 0 to 6, of this date object. 0 for Sunday, 1 for Monday, 2 for Tuesday, 3 for Wednesday, 4 for Thursday, 5 for Friday, or 6 for Saturday

Examples

1. find the day of week for the current date

let date = new Date();
console.log(date);
console.log(date.getDay());


Copyright @2022