JavaScript Date getDay()

The JavaScript date getDay() method is used to get the integer value between 0 and 6 that represents the day of the week based on the local time.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dateObj.getDay()
dateObj.getDay()
dateObj.getDay()

Return:
An integer value between 0 and 6.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
var bday = new Date("March 16, 2018 21:00:10");
document.writeln(bday.getDay())
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> var bday = new Date("March 16, 2018 21:00:10"); document.writeln(bday.getDay()) </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
var bday = new Date("March 16, 2018 21:00:10");
document.writeln(bday.getDay())
</script>
</body>
</html>