如果21600是6小时以秒,为什么我的柜台说7小时15分钟呢?我在这里错过了什么吗?
这是一个演示:
JS
var time_in_seconds = 26100; // 6 hours in seconds
setInterval(function() {
$('#countdown').html(seconds2time(time_in_seconds));
time_in_seconds--;
}, 1000);
function seconds2time(seconds) {
var hours = Math.floor(seconds / 3600);
var minutes = Math.floor((seconds - (hours * 3600)) / 60);
var seconds = seconds - (hours * 3600) - (minutes * 60);
var time = "";
if (hours != 0) {
time = hours+":";
}
if (minutes != 0 || time !== "") {
minutes = (minutes < 10 && time !== "") ? "0"+minutes : String(minutes);
time += minutes+":";
}
if (time === "") {
time = seconds+"s";
}
else {
time += (seconds < 10) ? "0"+seconds : String(seconds);
}
return time;
}
HTML
<span id="countdown"></span>
答案 0 :(得分:8)
26100与21600不同