<html xmlns="http://www.w3.org/1999/xhtml">
<head> </head>
<body></body>
</html>
<script>
var starTime = '2019-03-12';
var endTime = '2019-03-21';
function datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12-18格式
var dateSpan,
tempDate,
iDays;
sDate1 = Date.parse(sDate1);
sDate2 = Date.parse(sDate2);
dateSpan = sDate2 - sDate1;
dateSpan = Math.abs(dateSpan);
iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
return iDays
};
var Days = datedifference(endTime, starTime);
var Days2 = datedifference(starTime,endTime);
console.log(Days,Days2);
</script>
05-01 03:21