computeDuration(duration) {
if (!duration) {
return 0;
}
const days = Math.floor(duration / (1000 * 60 * 60 * 24));
const hours = Math.floor((duration % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
if (days > 0) {
return `${days} 天 ${hours} 小时 ${minutes} 分钟`;
}
if (hours > 0) {
return `${hours} 小时 ${minutes} 分钟`;
}
return `${minutes} 分钟`;
}
js毫秒数换算时长(days-hours-minutes)
最新推荐文章于 2023-05-11 14:31:22 发布