//计算两个日期相差的天数
function DateDiff() {
var sDate=$("input[name='daterangepicker_start']").val(),
eDate=$("input[name='daterangepicker_end']").val(),
iDays,sDate1,eDate1,startDate, endDate;
sDate1 = sDate.split("/");
startDate = new Date(sDate1[1] + '/' + sDate1[2] + '/' + sDate1[0]).getTime();
//转换为dd-MM-yyyy格式并转换为毫秒
eDate1 = eDate.split("/");
endDate = new Date(eDate1[1] + '/' + eDate1[2] + '/' + eDate1[0]).getTime();
iDays = parseInt(Math.abs(endDate - startDate) / 1000 / 60 / 60 / 24);
//把相差的毫秒数转换为天数
return iDays; //返回相差天数
}
//时间间隔计算结束日期
function DateDiff01() {
var sDate=$("#stedDate").val().substring(0,10),
inputDay=$('#difDay').val(),
inputDays,sDate1,startDate;
sDate1 = sDate.split("/");
startDate = new Date(sDate1[1] + '/' + sDate1[2] + '/' + sDate1[0]).getTime();
inputDays = (startDate+(inputDay*1000*60*60*24));
//console.log(sDate);
var newTime = new Date(inputDays); //得到普通的时间
var newYear =newTime.getFullYear();
var newMonth =newTime.getMonth()+1;
var newDay =newTime.getDate();
var newDate =newYear + '/' + newMonth+ '/' + newDay;
var farmate =sDate + " - " + newDate;
var eDate=$("input[name='daterangepicker_end']").val(newDate);
$("#stedDate").val(farmate);
console.log(farmate);
}