js获取两个日期相差的天数
作者:互联网
function dateDiffStr(startDateStr, endDateStr) {
var day = 0;
var separator = "-"; //日期分隔符
var date1 = startDateStr.substring(0, 10).split(separator);
var date2 = endDateStr.substring(0, 10).split(separator);
var date11 = new Date(date1[0], date1[1]-1, date1[2]);
var date22 = new Date(date2[0], date2[1]-1, date2[2]);
day = parseInt(Math.abs(date22-date11) / (1000 * 60 * 60 * 24));
return day;
}
标签:date1,date2,相差,天数,js,substring,separator,var,day 来源: https://www.cnblogs.com/sunline/p/15549216.html