【发布时间】:2015-05-06 03:14:04
【问题描述】:
目前我们有这个代码,它可以工作,只是它需要使用指定的时区,而不是用户的时区:
$('#countdown').countdown('<?php echo $date_end?>').on('update.countdown', function(event) {
var format = '%-S second%!S';
if (event.offset.years > 0 || event.offset.weeks > 0 || event.offset.days > 0 || event.offset.hours > 0 || event.offset.minutes > 0) {
if(event.offset.minutes > 0) {
format = '%-M minute%!M ' + format;
}
if(event.offset.hours > 0) {
format = '%-H hour%!H ' + format;
}
if(event.offset.days > 0) {
format = '%-d day%!d ' + format;
}
if(event.offset.weeks > 0) {
format = '%-w week%!w ' + format;
}
}
$(this).html(event.strftime(format));
}).on('finish.countdown', function(event) {
$(this).html('Finished');
});
我见过几个添加时区的例子,但没有一个像我们一样使用 jquery 倒计时插件。
关于如何将 +10 添加为当前时区的任何想法?所以它使用那个而不是用户的时区?
谢谢。
【问题讨论】:
-
我不确定我是否理解您使用插件的方式,或者它是否与此插件相同:keith-wood.name/countdown.html#zones 但是,我在网站上使用了该插件并通过它是在时区 -7 中倒计时的日期/时间,如下所示:jQuery('#countdown').countdown({until: new Date(2020, 1-1, 11, 5, 35, 35), timezone:-7 , 格式:'YODHMS', 紧凑: true});也许这有帮助?