0

I'm from The Netherlands and I'm in school. I have a date but now I want to show a weekday from that date.

<!DOCTYPE html>
<html>
<head>
    <script>
    function getWeekday(d) {
    alert (d);
    var date = new Date();
    var weekday = new Array(7);
    weekday[0] = "Zondag";
    weekday[1] = "Maandag";
    weekday[2] = "Dinsdag";
    weekday[3] = "Woensdag";
    weekday[4] = "Donderdag";
    weekday[5] = "Vrijdag";
    weekday[6] = "Zaterdag";
    }


    function d() {
    document.getElementById("Weekdag").innerHTML = getWeekday ("2050-01-01");
    }
</script>
</head>
<body>

<p>Laat een weekdag zien</p>

<button onclick="d()">Klik voor weekdag</button>

<p id="Weekdag"></p>

</body>
</html>
Termininja
  • 6,620
  • 12
  • 48
  • 49
Dimitri
  • 69
  • 1
  • 7
  • 1
    Asking questions on Stack Overflow is not an alternative to research. First, do basic research, including [a thorough search here](/search?q=%5Bjs%5D+get+day+of+week), and then when posting your question explain what research you've done. – T.J. Crowder Dec 02 '16 at 12:34
  • Also check this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array – mplungjan Dec 02 '16 at 12:39
  • Here is a working code: http://codepen.io/yosvelquintero/pen/yVpwRW – Yosvel Quintero Dec 02 '16 at 12:47

1 Answers1

3

using your Date instance, call getDay(). Sunday is 0 and so on.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445