order 7.25
This commit is contained in:
@@ -43,5 +43,29 @@ const common = {
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
/**
|
||||
* 将 php 时间戳转化为时分秒
|
||||
* @param { String } timestamp php 时间戳
|
||||
* @param { String } format 间隔符 默认 '26:14:25'
|
||||
* @return { String } 格式化时间
|
||||
*/
|
||||
getLineTime({ timestamp, format } = {}) {
|
||||
const days = Math.floor(timestamp / (24 * 3600 * 1000));
|
||||
//计算出小时数
|
||||
const leave1 = timestamp % (24 * 3600 * 1000) // 计算天数后剩余的毫秒数
|
||||
let 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)
|
||||
// 把天数算在小时里
|
||||
hours = days * 24 + hours;
|
||||
let result;
|
||||
if(format) result = hours + format + minutes + format + seconds;
|
||||
else result = hours + ':' + minutes + ':' + seconds;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
export default common
|
||||
Reference in New Issue
Block a user