900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 根据时间戳获取总用时(天时分秒)

根据时间戳获取总用时(天时分秒)

时间:2018-10-04 11:26:18

相关推荐

根据时间戳获取总用时(天时分秒)

//获取总用时(天时分秒)

export const getTotalTime = (time) => {

if (!time) {

return "";

}

let s = time / 1000;

let m = s / 60;

let h = m / 60;

let day = h / 24;

if (Math.floor(day)) {

return Math.floor(day) + "天" + Math.floor(h) % 24 + "时" + Math.floor(m) % 60 + "分";

} else if (!Math.floor(day) && (Math.floor(h) % 24 != 0)) {

return Math.floor(h) % 24 + "时" + Math.floor(m) % 60 + "分";

} else {

return Math.floor(m) % 60 + "分";

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。