如何在Jquery中找到两个日期之间的差异(天数),其格式为 dd / mm / yy ?
这就是我的尝试:
var start = $('#start').val(); //30/04/2014
var end = $('#end').val(); // 15/05/2014
var diff = new Date(end - start);
var days = diff/1000/60/60/24
答案 0 :(得分:1)
var startDate= $("#start").datepicker('getDate');
var endDate= $("#end").datepicker('getDate');
var diffInDays = Math.round((startDate.getTime()- endDate.getTime())
/1000*60*60*24);
答案 1 :(得分:1)
上述代码略有改动:
var startDate= $("#start").datepicker('getDate');
var endDate= $("#end").datepicker('getDate');
var diffInDays = Math.round((endDate.getTime()- startDate.getTime())/(1000*60*60*24));