function TimeDifference(Stime, Ttime) {
//判断开始时间是否大于结束日期
if (Stime > Ttime) {
console.log("开始时间不能大于结束时间!");
return false;
}
if(Ttime && Stime){
var startDate = new Date(Stime);
var stopDate = new Date(Ttime);
var startTime = startDate.getTime();
var stopTime=stopDate.getTime();
var cTime=Number(stopTime)-Number(startTime);
var secondTime=cTime/1000/60;
return parseInt(secondTime);
}else{
return 0;
}
}
//Stime :开始时间 Ttime:结束时间
console.log(TimeDifference("2020-03-11 10:22:22","2020-03-11 10:29:22"));
//结果:7