JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Date Right Arrow getDay()

getDay()  Date  instance method

Description

Returns the locale specific day of the week (0-6) for the specified date. 0 = Sunday, 1 = Monday etc.

Syntax


Signature Description
aDate.getDay()Returns the locale specific day of the week (0-6) for the specified date. 0 = Sunday, 1 = Monday etc.

Parameters

None.

Examples

The code below shows examples of the getDay() method of Date.




// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);

// Get Day of the month.
alert(todaysDate.getDay() + ' = Day of week as a number');

// Use an array to display the date as a string.
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 
            'Thursday', 'Friday', 'Saturday']; 
alert(days[todaysDate.getDay()] + ' = Day of week as a string');


Press the button below to action the above code:



Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times




  


go to home page Homepage go to top of page Top