HY!
我正在使用Kelvin Luck的jquery.datePicker示例。 (http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerClickInput.html)
如何计算Date1和Date2之间的天数?
伙计们!
答案 0 :(得分: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);
}
答案 1 :(得分:1)
不要忘记函数名称Math。:
return Math.round(diff / days);