我正在使用Justin Kimbrell FlipClock.js(来自flipclockjs.com):
$(function(){
FlipClock.Lang.Custom = { days:'Dagar', hours:'Timmar', minutes:'Minuter', seconds:'Sekunder' };
var opts = {
clockFace: 'DailyCounter',
countdown: true,
language: 'Custom'
};
var countdown = 1475924400 - ((new Date().getTime())/1000); // from: 10/08/2016 12:00 pm +0100
countdown = Math.max(1, countdown);
$('.clock-builder-output').FlipClock(countdown, opts);
});
它似乎运作良好。但是我想添加另一个以相同方式工作的计数器,但是从过去的设定日期和时间算起来。 有人可以帮我这个吗?
答案 0 :(得分:2)
自己解决了。 - 使用FlipClock().setTime()
并发送自时钟应该为00:00:00(开始时间)以来的秒数。像这样:
FlipClock.Lang.Custom = { days:'Dagar', hours:'Tim', minutes:'Min', seconds:'Sek' };
var startDate = new Date('Fri Jan 8 2016 12:00:00 GMT+0200'); //What date to start counting from
var now = Math.floor(Date.now()/1000); //Current timestamp in seconds
var clockStart = now - startDate.getTime()/1000; //What to set the clock at when page loads
var clock2 = $('.clock2').FlipClock(opts).setTime(clockStart); //Start clock