Date.getDay()
JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE 3+, Opera3+ Syntax
date.getDay()
Description
The getDay() method returns the day of the week expressed as an integer from 0 (Sunday) to 6 (Saturday).
Example
The code in Listing 6.72 uses the getDay() method to return the day of the week expressed as an integer. This number is then converted to a string representation of the day of the week.
Listing 6.72 Using the getDate() Method to Return the Day of the Week
<html> <script language="JavaScript"> <!-- Hide //This function converts the day from a number to //a string and returns the string. function getDayString(num) { var day; //Create a local variable to hold the string switch(num) { case 0: day="Sunday"; ... |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.