WishMeLz

生活其实很有趣

JS计算两个日期相差天数

function Start(startDateString, endDateString) {
  var startDate = Date.parse(startDateString);
  var endDate = Date.parse(endDateString);
  if (startDate > endDate) {
    return 0;
  }
  if (startDate == endDate) {
    return -1; //相等
  }
  var days = (endDate - startDate) / (1 * 24 * 60 * 60 * 1000);
  return days;
}