1

嗨!

我正在使用来自 Kelvin Luck 的 jquery.datePicker 示例。(http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerClickInput.html

如何计算 Date1 和 Date2 之间的天数?

伙计们!

4

2 回答 2

2

像这样的东西:

function returnNumberOfDaysBetweenTwoDates(input1, input2) {
    var date1 = new Date(input1.value);
    var date2 = new Date(input2.value);

    var minutes = 1000*60;
    var hours = minutes*60;
    var days = hours*24;

    var diff = Math.abs(date1.getTime() - date2.getTime());

    return round(diff / days);
}
于 2009-05-12T22:44:28.163 回答
1

不要忘记函数名称 Math.:

return Math.round(diff / days);
于 2011-11-03T08:19:53.377 回答