我需要定时器在代码点火器,mysql和ajax,因为时间在几天来从数据库为每个产品。
<td id="timer"><?=$data['auction_end_time']?></td>数据在几天内来自数据库,我想显示timer.这是我网站的链接,你可以看到。
带我去.!
发布于 2018-07-31 06:31:30
假设我们有以下php函数(这可以改进)
function auction_end_time($future_date) {
$now = new DateTime();
$future_date = new DateTime($future_date);
if($future_date <= $now)
return 'This offer has expired!';
$interval = $future_date->diff($now);
return $interval->format("%a days %h:%i:%s");
}在html代码中
<td id="timer"><?=auction_end_time($data['auction_end_time'])?></td>这个溶液是静态的。对于动态倒计时,您可以使用jquery插件,我找到了这个jQuery.countdown插件
请参阅jsfiddle.net上的示例
https://stackoverflow.com/questions/51600876
复制相似问题