两个时间差值的计算后 转换为时:分钟:秒的形式
// 时间的计算
time是差值
var chazhi = this.now - this.$moment(this.createTime).unix();
transTime(time) {
if (time === "") {
return "";
} else {
time = time * 1000;
var result = "";
if (time >= 1000) {
// console.log(time, "2587421");
var day = parseInt(time / (24 * 60 * 60 * 1000));
var hour = parseInt(
(time % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000)
);
var m1 = time % (24 * 60 * 60 * 1000);
var m2 = m1 % (60 * 60 * 1000);
var m3 = m2 / (60 * 1000);
var minute = parseInt(
((time % (24 * 60 * 60 * 1000)) % (60 * 60 * 1000)) / (60 * 1000)
);
var second = parseInt(
(((time % (24 * 60 * 60 * 1000)) % (60 * 60 * 1000)) %
(60 * 1000)) /
1000
);
if (day != 0) {
result += day + "天";
}
if (hour != 0) {
this.hour = (hour + "").padStart(2, "0");
result += hour + "时";
}
if (minute != 0) {
this.minute = (minute + "").padStart(2, "0");
result += minute + "分";
}
if (second != 0) {
this.second = (second + "").padStart(2, "0");
result += second + "秒";
}
}
if (result == "") {
result = "0秒";
}
// console.log(result, "258741");
return result;
}
},
加班万岁!