mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-15 13:56:45 +08:00
提交部分
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user