我如何从约会中获得一天

时间:2016-12-02 12:31:54

标签: javascript html5

我来自荷兰,我在学校。我有约会,但现在我要显示该日期的工作日。

<!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>

1 个答案:

答案 0 :(得分:3)

使用Date个实例,请致电getDay()。星期日是0,依此类推。