js毫秒轉時分秒
const formatSeconds = (value) => {
if (value === 0 || value < 1000) return '0秒';
var timestamp = parseInt(value) / 1000; // 毫秒轉秒
// 小時取余數
const remainder = timestamp % 3600
// 時、分、秒
let hour, minute, second;
if (remainder === 0) { // 整除 小時
hour = parseInt(timestamp / 3600);
} else {
hour = parseInt(timestamp / 3600);
let remainderMinute = remainder % 60;
if (remainderMinute === 0) { // 整除 分鐘
minute = parseInt(remainder / 60);
} else {
minute = parseInt(remainder / 60);
second = parseInt(remainderMinute);
}
}
let text = '';
if (hour > 0) {
text += hour + '時';
}
if (minute > 0) {
text += minute + '分';
}
if (second > 0) {
text += minute + '秒';
}
return text;
}
哇!又賺了一天人民幣

浙公網安備 33010602011771號