Prev Demo
JavaScript
>
Getday() Method
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Returning name of the present day of a week.</h1> <p>Click the below button to get the name of the Day.</p> <input type="button" value="Click" onclick="myDate()" /> <p id="myId"></p> <script> function myDate() { var a = new Date(); var days = new Array(7); days[0] = "Sunday"; days[1] = "Monday"; days[2] = "Tuesday"; days[3] = "Wednesday"; days[4] = "Thursday"; days[5] = "Friday"; days[6] = "Saturday"; var r = days[a.getDay()]; document.getElementById("myId").innerHTML = r; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output