JS为时间表添加时间

时间:2017-04-09 05:19:22

标签: javascript math time add minute

我正在尝试创建时间表页面。我正在努力弄清楚如何相加/减去彼此的时间,因为它不会增加分钟。可以有人请帮助,我不能在网上得到任何答案,所以希望有人在这里能够提供帮助。 / p>

这只是回归时间而不是分钟,我希望答案很简单,我只是错过了什么?

这是我的代码:

<button onclick="myFunction()">Cal</button><BR><BR>

<script>
function myFunction() {

    var D1S = parseFloat(document.getElementById("D1S").value)
    var D1F = parseFloat(document.getElementById("D1F").value)
        document.getElementById("day1").innerHTML = D1F-D1S;

    var D2S = parseInt(document.getElementById("D2S").value)
    var D2F = parseInt(document.getElementById("D2F").value)
        document.getElementById("day2").innerHTML = D2F-D2S;

    var D3S = parseInt(document.getElementById("D3S").value)
    var D3F = parseInt(document.getElementById("D3F").value)
        document.getElementById("day3").innerHTML = D3F-D3S;

    var D4S = parseInt(document.getElementById("D4S").value)
    var D4F = parseInt(document.getElementById("D4F").value)
        document.getElementById("day4").innerHTML = D4F-D4S;

    var D5S = parseInt(document.getElementById("D5S").value)
    var D5F = parseInt(document.getElementById("D5F").value)
        document.getElementById("day5").innerHTML = D5F-D5S;

    var D6S = parseInt(document.getElementById("D6S").value)
    var D6F = parseInt(document.getElementById("D6F").value)
        document.getElementById("day6").innerHTML = D6F-D6S;

    var D7S = parseInt(document.getElementById("D7S").value)
    var D7F = parseInt(document.getElementById("D7F").value)
        document.getElementById("day7").innerHTML = D7F-D7S;


document.getElementById("total").innerHTML = (D1F-D1S) + (D2F-D2S) + (D3F-D3S) + (D4F-D4S) + (D5F-D5S) + (D6F-D6S) + (D7F-D7S); 

}
</script>

Monday Start <input id="D1S" type="time" value="0.0"> Finish <input id="D1F" type="time" value="0.0"> <p id="day1"></p><BR>
Tuesday Start <input id="D2S" type="time" value="0.0"> Finish <input id="D2F" type="time" value="0.0"> <p id="day2"></p><BR>
Wednesday Start <input id="D3S" type="time" value="0.0"> Finish <input id="D3F" type="time" value="0.0"> <p id="day3"></p><BR>
Thursday Start <input id="D4S" type="time" value="0.0"> Finish <input id="D4F" type="time" value="0.0"> <p id="day4"></p><BR>
Friday Start <input id="D5S" type="time" value="0.0"> Finish <input id="D5F" type="time" value="0.0"> <p id="day5"></p><BR>
Staurday Start <input id="D6S" type="time" value="0.0"> Finish <input id="D6F" type="time" value="0.0"> <p id="day6"></p><BR>
Sunday Start <input id="D7S" type="time" value="0.0"> Finish <input id="D7F" type="time" value="0.0"> <p id="day7"></p><BR><BR>
Total - <p id="total"></p>

0 个答案:

没有答案