[英]jQuery.countdown issue on seconds countdown
我需要 24 小时会话倒计时。 我正在使用 jQuery.countdown。 下面的代码给了我 12 小时的倒计时,为什么不是 24 小时? 如果我设置了 20 秒或 10 秒的范围,倒计时会说它完成了。 有人看到这个错误吗?
<?php
date_default_timezone_set('Europe/Berlin');
$_SESSION['code_end'] = time() + 86400;
?>
<div id="getting-started"></div>
<script type="text/javascript">
$("#getting-started").countdown("<?php echo date('Y/m/d h:i:s', $_SESSION['code_end']);?>")
.on('update.countdown', function(event) {
var format = '%H:%M:%S';
if(event.offset.totalDays > 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) {
alert("session End");
$(this).html('This offer has expired!')
.parent().addClass('disabled');
});
</script>
您需要为倒计时功能提供 24H 格式。
您的代码:
$("#getting-started").countdown("<?php echo date('Y/m/d h:i:s', $_SESSION['code_end']);?>")
需要是:
$("#getting-started").countdown("<?php echo date('Y/m/d H:i:s', $_SESSION['code_end']);?>")
(24H 格式的大写 H)
这里有一个工作示例: https : //www.seeque-secure.dk/demo.php?id=jQuery.countdown+issue+on+seconds+countdown
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.