THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript getDay() Method

❮ JavaScript Date Object

Example

Return the day of the week:

var d = new Date();
var n = d.getDay();
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The getDay() method returns the day of the week (from 0 to 6) for the specified date.

Note: Sunday is 0, Monday is 1, and so on.


Browser Support

Method
getDay() Yes Yes Yes Yes Yes

Syntax

Date.getDay()

Parameters

None


Technical Details

Return Value: A Number, from 0 to 6, representing the day of the week
JavaScript Version: ECMAScript 1

More Examples

Example

Return the name of the weekday (not just a number):

var d = new Date();
var weekday = new Array(7);
weekday[0] =  "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var n = weekday[d.getDay()];
Try it Yourself »

❮ JavaScript Date Object