dsfdsf8888 2013-05-27 09:02
浏览 33
已采纳

如何计算表格中日期之间的差异? 日期(日,月,年)位于3个不同的下拉框中

How can I calculate the difference between to dates in a form? The dates (day,Month,year) are in 3 different Drop-down boxes. So is it some how possible to get the value of the selected Drop-down which we define in the option tag?

  • 写回答

1条回答 默认 最新

  • douzhangwei5265 2013-05-27 09:07
    关注

    You can do:

    var dateA = new Date($("#yearA").val(), $("#monthA").val(), $("#dayA").val());
    var dateB = new Date($("#yearB").val(), $("#monthB").val(), $("#dayB").val());
    var diff = Math.abs(dateA - dateB);
    

    Which will give you the difference between the two dates in milliseconds.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?