我正在尝试使用翻转时钟创建特定日期的倒计时,而无需重置计时器或不同时区的人看到不同的数字。例如,我想倒计时到 2 月 20 日上午 12:00 MST。
我的问题是当浏览器刷新到0后时钟会重置,时间显示为负数。如果人们以当前配置查看此时钟,则会在他们的时区倒计时到 2 月 20 日凌晨 12 点。
我已经开始倒计时新年编译时钟并设置我的日期,但不确定如何解决时区和重置问题。
var clock;
$(document).ready(function() {
// Grab the current date
var currentDate = new Date();
// Set some date in the future. In this case, it's always Jan 1
var futureDate = new Date(currentDate.getFullYear() + 0, 1, 20, 0, 0);
// Calculate the difference in seconds between the future and current date
var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
// Instantiate a coutdown FlipClock
clock = $('.clock').FlipClock(diff, {
clockFace: 'DailyCounter',
countdown: true,
showSeconds: false,
callbacks: {
stop: function() {
$('.message').html('The clock has stopped!');
}
}
});
});