//计算时间差函数
difference() {
if (this.formData.startTime!==''&&this.formData.endTime!==''){
let start = this.formData.startTime;
let end = this.formData.endTime;
console.log(start,end,88888)
let dateBegin = new Date(start.substring(0,10));
let dateEnd = new Date(end.substring(0,10));
let dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数
let dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)) +1;//计算出相差天数
if (end.substring(11,13) < this.flyTime ){ //this.timeNode从字典表里面取,飞机起飞时间15时
dayDiff = dayDiff -0.5;
}else if (end.substring(11,13) == this.flyTime ){
if (end.substring(14,15) ==0 && end.substring(15,16) ==0 ){
dayDiff = dayDiff- 0.5;
}
}
if (start.substring(11,13) > this.flyTime){
dayDiff = dayDiff- 0.5;
}else if (start.substring(11,13) == this.flyTime){
if (start.substring(14,15) >0 ){
dayDiff = dayDiff- 0.5;
}else if (start.substring(15,16) >0 ){
dayDiff = dayDiff- 0.5;
}
}
this.formData.businessTripDays = dayDiff;
}else {
this.formData.businessTripDays = 0;
}
},
年月日时分的时间差函数,统计两个时间的差值
最新推荐文章于 2022-03-25 09:20:45 发布