MVC5
我希望比较预订的结束日期和开始日期,以找到两者之间的总小时数。日期时间格式为DD / MM / YYYY HH:MM
var hours = (endDate - startDate).TotalHours;
alert('Total Hours Difference ' + hours);
输出显示 “总时差未定义”
工作解决方案
startDate = parseInt(new Date(startDate).getTime() / 1000);
endDate = parseInt(new Date(endDate).getTime() / 1000);
var timeDiff = (endDate - startDate) / 3600; // will give difference in hrs
alert('Total Hours Differece' + timeDiff);