VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-date-getday-method/

⇱ JavaScript Date getDay() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Date getDay() Method

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:

  • This method does not accept any parameters.

Return Values:

  • It returns the day of the week for the given date. The day of the week will be returned in the form of an integer value ranging from 0 to 6 means 0 for Sunday, 1 for Monday, and so on till 6 for Saturday.

Example 1: In this example, we will write a simple program to get the number of day of the week using getDay().

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.

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.

Output:

NaN

Example 4: If nothing as a parameter is given, it returns the current day of the current week.

Output: It returns the current day of the week.

5

Supported Browsers:

The browsers supported by JavaScript Date.getDay() method are listed below:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
Comment