+ 2
Why this code return Wednesday
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var day; switch (new Date().getDay()) { case 0: day = "Sunday"; break; case 1: day = "Monday"; break; case 2: day = "Tuesday"; break; case 3: day = "Wednesday"; break; case 4: day = "Thursday"; break; case 5: day = "Friday"; break; case 6: day = "Saturday"; } document.getElementById("demo").innerHTML = "Today is " + day; </script> </body> </html>
2 Antworten
+ 2
It is okay. The Date().getDay() returns the calculated number of day in the week (Sunday is 0, Monday is 1, Thursday 2, Wednesday 3)...
0
Sorry Tuesday is 2