Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.getDay

Returns the day of the week — a number from 0 to 6, where 0 is Sunday.

Available since: ES1

Syntax

date.getDay()

Return value

numberThe day of the week from 0 (Sunday) to 6 (Saturday).

Examples

March 15, 2026 is a Sunday:

console.log(new Date(2026, 2, 15).getDay());

Output:

0

A weekend check:

const day = new Date(2026, 2, 14).getDay();
 
console.log(day === 0 || day === 6 ? 'weekend' : 'weekday');

Output:

weekend

Notes

The week starts on Sunday here. The day name in any language comes from toLocaleDateString('en-US', { weekday: 'long' }).

See also

Related recipes

In the tutorial

  • Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.

Thanks for reading!

Donate to the site — we work hard for you.