时间戳
将这个日期转换为时间戳
ruleForms.useBeginDate =( this.$moment(ruleForms.useBeginDate).valueOf())/1000;
现在的时间
now: this.$moment(new Date()).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;
}
},
},
加班万岁!