尝试使用来自php的UNIX时间戳的jQuery Countdown
正如标题所说,我正面临一个问题,显示正确的左侧时间到结束日期。
我正在使用这个jquery插件: http : //keith-wood.name/countdown.html
假设我们的时间戳由PHP脚本生成,如下所示: $end_date = strtotime($row4['end']); // 2012-05-09 06:00:00 becomes 1336536000
$end_date = strtotime($row4['end']); // 2012-05-09 06:00:00 becomes 1336536000
我用它( $i
在循环中使用):
$('.count-').countdown({until: new Date( * 1000), layout: '{dn} days {hnn} hrs {mnn} min {snn} sec', compact: true});
现在是06:21 AM。 而不是预期的1天左边的结果,我得到“1天17小时04分21秒”。
我在这里想念的是什么?
我已经使用API了很长一段时间,但我似乎无法弄清楚你的代码是什么。 也许(但也许只是)你正在使用untill
属性错误。
我经常使用的代码:
$(function(){ var countdown = $('#countdown'), ts = new Date(), finished = true; if((new Date()) > ts) { finished = false; } $('#cool-countdown').countdown({ timestamp : ts, callback : function(days, hours, minutes, seconds) { var message = ""; message += days + " days, "; message += hours + " hours, "; message += minutes + " minutes, "; message += seconds + " seconds "; message = (finished ? "Countdown finished" : "left untill the New Year"); countdown.html(message); } }); });
显然你应该将它扩展为feature singular。