我有一个严重的问题,我无法解决。我需要进行多个倒计时,但在我的代码中,只有一个倒计时可以正常工作。我不明白为什么其他日期时间无法读取。我正在使用数据库来获取日期时间。
这是我的代码:
$stmt4 = $mybd->prepare($query3);
$stmt4->bind_param("s",$cat);
$stmt4->execute();
$stmt4->bind_result($idVoucher,$titulo,$descricao, $precoOriginal, $desconto,$data, $nome, $nomeImagem);
while($stmt4->fetch()){
if($cat == $nome){
if($idVoucher != $idVoucher2){
echo "<input id='data2' type='hidden' value='$data' />";
我使用这个脚本倒计时:
$(function(){
var data = $('#data').val();
var date_split = data.split(" ");
var date = date_split[0];
date = date.split("-");
var time = date_split[1];
time = time.split(":");
var data1 = $('#data2').val();
var date_split1 = data1.split(" ");
var date1 = date_split1[0];
date1 = date1.split("-");
var time1 = date_split1[1];
time1 = time1.split(":");
var note = $('#note'),
ts = new Date(date[0], date[1] - 01,date[2], time[0], time[1],time[2]),
newYear = true;
var note1 = $('#note1'),
ts2 = new Date(date1[0], date1[1] - 01,date1[2], time1[0], time1[1],time1[2]),
newYear = true;
/* if((new Date()) > ts){
// The new year is here! Count towards something else.
// Notice the *1000 at the end - time must be in milliseconds
ts = (new Date()).getTime() + 10*24*60*60*1000;
newYear = false;
} */
$('#endtime_1320').countdown({
timestamp : ts,
callback : function(days, hours, minutes, seconds){
var message = "";
message += days + " day" + ( days==1 ? '':'s' ) + ", ";
message += hours + " hour" + ( hours==1 ? '':'s' ) + ", ";
message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " and ";
message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />";
}
});
$('#endtime_1321').countdown({
timestamp : ts2,
callback : function(days, hours, minutes, seconds){
var message = "";
message += days + " day" + ( days==1 ? '':'s' ) + ", ";
message += hours + " hour" + ( hours==1 ? '':'s' ) + ", ";
message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " and ";
message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />";
}
});
});
我该如何解决这个问题?将我的 dateTimes 保存到数组中并使用到我的脚本中?对于这种情况,我是怎么做到的?
谢谢