为什么我没有得到正确的时间?
问题描述:
如果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>
答
26100是不一样的21600
OMG,我需要睡眠,LMAO!谢谢 – 2012-02-18 07:47:39
如果这*不是答案,我会说“应该是一个评论”。 – 2012-02-18 07:54:49
我还在嘲笑自己 – 2012-02-18 08:00:19