RE:http://www.class.pm/files/jquery/classycountdown/
这个简单的jquery倒计时插件准确呈现了我想要的内容,但此时的触发器代码只设置了相对于页面加载的目标结束时间。
$('.countdown').ClassyCountdown({
theme: "flat-colors",
end: $.now() + 10000
});
我最终要做的是设置相对于特定GMT / UTC日期和时间的结束时间。
这是可能的,它是如何完成/编码的?
答案 0 :(得分:3)
你需要挖掘Unix/Epoch时间。
现在和结束参数分别用于指定大纪元时间的开始和结束时间。 jQuery函数$ .now()以毫秒的形式返回当前时间。将返回值除以1000,其余的非常简单。
假设您想要倒计时到2015年12月25日上午9点。您需要calculate the Epoch time to the date first。此示例的Epoch时间戳为1451034000.这是以秒为单位,而不是毫秒。因此,代码的相关部分应如下所示:
$('#countdown').ClassyCountdown({
now: $.now()/1000 ,
end: '1451034000' ,
...
...
});
答案 1 :(得分:2)
假设您想倒计时到2015年12月25日上午9点:
$('.countdown').ClassyCountdown({
theme: "flat-colors",
now: $.now() / 1000,
end: Date.UTC(2015, 11, 25, 9, 0, 0) / 1000
});
请注意,月份计数从0开始。