X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript getDay() Method

Date Object Reference JavaScript Date Object

Example

Return the day of the week:

var d = new Date();
var n = d.getDay();

The result of n will be:


Try it yourself »


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

Internet Explorer Firefox Opera Google Chrome Safari

The getDay() method is supported in all major browsers.


Syntax

Date.getDay()

Parameters

None.

Return Value

Type Description
Number A Number, from 0 to 6, representing the day of the week

Technical Details

JavaScript Version: 1.0


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()];

The result of n will be:


Try it yourself »


Date Object Reference JavaScript Date Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook