提交部分

This commit is contained in:
kclf
2022-11-23 15:39:22 +08:00
parent 6b210e8a1a
commit ff8213ccbf
5 changed files with 1219 additions and 1469 deletions

View File

@@ -84,3 +84,36 @@ export function filterCommon(arr, key) {
});
return newData;
}
export function getdateToTime(date) {
let now = new Date(parseInt(date)),
y = now.getFullYear(),
m = now.getMonth() + 1,
d = now.getDate(),
hh = now.getHours(),
mm = now.getMinutes();
return `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d} ${hh}:${mm}`;
}
//计算两个时间之间的时间差 多少天时分秒
export function intervalTime(startTime) {
const curTime = new Date().getTime(); //计算当前时间戳
const date3 = curTime - startTime; //时间差的毫秒数
//计算出相差天数
const days = Math.floor(date3 / (24 * 3600 * 1000));
//计算出小时数
const leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
const hours = Math.floor(leave1 / (3600 * 1000));
//计算相差分钟数
const leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
const minutes = Math.floor(leave2 / (60 * 1000));
//计算相差秒数
const leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
const seconds = Math.round(leave3 / 1000);
return {
days,
hours,
minutes,
seconds,
};
}