前台怎样获取两个datetime类型的值 相差的天数
var Date=gridRows[0].get("FormDate");
var Time=gridRows[0].get("MaintainTime");
两个datetime类型 怎样获取其相差的天数?
[解决办法]
$(function () {
alert(GetDateDiff('2012-01-20','2012-01-23'));//3
})
function GetDateDiff(startDate, endDate) {
var startTime = new Date(Date.parse(startDate.replace(/-/g, "/"))).getTime();
var endTime = new Date(Date.parse(endDate.replace(/-/g, "/"))).getTime();
var dates = Math.abs((startTime - endTime)) / (1000 * 60 * 60 * 24);
return dates;
}