目前我们有这个代码,除了需要使用指定的时区而不是用户的时区外,它有效:
$('#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;
} …Run Code Online (Sandbox Code Playgroud) 我还没有找到任何好的例子,但是我想找一些简单的jQuery示例进行倒计时,30 seconds一旦点击它就会刷新当前页面0.
每个计数应显示在一个<div>元素中.
我正在创建一个便士拍卖网站,主页上有几次拍卖。每次拍卖都会根据mysql日期格式中的日期获得自己的计时器,该日期格式为“ Ymd H:i:s”。
该代码运行正常,并且所有计时器在Firefox和Chrome上都开始完美地倒计时,但是在Safari中,该数字显示NaN:NaN:NaN
这是我的功能,它使用Keith Wood的jquery countdown插件:
function updateTimers() {
$( ".il-timer" ).each(function( index ) {
var timer = $(this);
var end_date = $(timer).attr('data-end-date');
var auction_id = $(timer).attr('data-auction-id');
var end = new Date(Date.parse(end_date,"yyyy-mm-dd hh:mm:ss"));
$('#auction_listing_timer_'+auction_id).countdown({until: end, format: 'HMS', compact: true, description: ''});
//Do it every 10 seconds...
setTimeout(function(){
updateTimers();
}, 10000);
});
};
Run Code Online (Sandbox Code Playgroud) 我正在开发基于优惠券的网站,我需要在数据表中使用倒计时脚本(http://hilios.github.io/jQuery.countdown/)。
我遇到页面更改事件停止第一页的计时器,并且计数在其他页面上不起作用。
这是我每次加载页面时更新计数器的代码
$('#sample_2').on( 'page.dt', function () {
alert("page changed");
$('[data-countdown]').each(function() {
var $this = $(this), finalDate = $(this).data('countdown');
$this.countdown(finalDate, function(event) {
$this.html(event.strftime('%D days %H:%M:%S'));
});
}).on('finish.countdown', function(event) {
$(this).addClass("label label-sm label-danger");
$(this).html('This offer has expired!');
});
} );
Run Code Online (Sandbox Code Playgroud)
HTML代码
<tr>
<td>f2 coupon</td>
<td>
<div data-countdown="2015-05-18 12:09:00" class="label label-sm label-success">20 days 15:04:54</div>
</td>
<td class="numeric">1</td>
<td class="numeric">1</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
如果需要,请随时询问更多信息
请指教。
-尼克斯