我有這個計數器,我想從一個特定的時間戳(1385132831.818785)開始,而不是從0開始。我該怎麼做?JavaScript從時間戳開始計數
startTimer: function(el) {
var counter = 0,
cDisplay = $(el);
var format = function(t) {
var minutes = Math.floor(t/600),
seconds = Math.floor((t/10) % 60);
minutes = (minutes === 0) ? "" : (minutes === 1)? minutes.toString() + ' min ' : minutes.toString() + ' mins ';
seconds = (seconds === 0) ? "" : seconds.toString() + ' secs';
cDisplay.html(minutes + seconds);
};
setInterval(function() {
counter++;
format(counter);
},100);
}
'var counter = 1385132831.818785,' – adeneo
如何返回2308555分鐘10秒 – Newcoma
您的時間戳將近44歲; )。 – Teemu