1.毫秒转换时间
formatDate(date) {
var date = new Date(date);
var YY = date.getFullYear() + "-";
var MM =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return YY + MM + DD;
}
2.时间转换毫秒
transitionTime() {
function dateToMs(date) {
let result = new Date(date).getTime();
return result;
}
}
3.向上保留两位小数
const upFloat = (data) => {
let num = data * 1000
let result = Math.ceil(num) / 1000
if (String(result).substring(String(result).indexOf('.')).length > 3) {
return Math.ceil(result * 100) / 100
} else {
return result
}
}