Last Updated : 11 Jul, 2025
JavaScript Date getDay() Method is used to fetch the day of a week(0 to 6) from a given Date object.
Syntax:DateObj.getDay()Parameters:
Example 1: In this example, we will write a simple program to get the number of day of the week using getDay().
javascript
// Here a date has been assigned
// while creating Date object
let A = new Date('October 15, 1996 05:35:32');
// Day of the week from above Date Object is
// being extracted using getDay()
let Day = A.getDay();
// Printing day of the week
console.log("Number of Day: " +Day);
Output:
Number of Day: 2
Example 2: If the date of the month is not given, by default the function considers it as the first date of the month and hence accordingly it returns the day of the week. It is an exceptional case.
javascript
// Here a date has been assigned
// While creating a Date object
let A = new Date('July 1974');
let B = A.getDay();
// Printing day
console.log("Number of Day: "+B);
Output:
Number of Day: 1
Example 3: The date of the month should lie between 1 to 31 because none of the months have a date greater than 31 that is why it returns NaN i.e, not a number because the date for the month does not exist.
javascript
// Here a date has been assigned
// while creating Date object
let A = new Date('October 35, 1996 05:35:32');
// Day of the week from above Date Object
// is being extracted using getDay()
let B = A.getDay();
// Printing day of the week.
console.log(B);
Output:
NaN
Example 4: If nothing as a parameter is given, it returns the current day of the current week.
javascript
// Creating Date Object
let A = new Date();
// day of the week from above object
// is being extracted using getDay().
let B = A.getDay()
// Printing day of the week.
console.log(B);
Output: It returns the current day of the week.
5Supported Browsers:
The browsers supported by JavaScript Date.getDay() method are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4