<p id="t_h"></p>
<p id="t_m"></p>
<p id="t_s"></p>
<script type="text/javascript">
function getRTime() {
var end = '{$time}'.split(" ") 2017-09-06 00:24:35
var e1 = end[0].split("-")
e1[1] = e1[1] - 1
var e2 = end[1].split(":")
var c=e1.concat(e2)
var EndTime = new Date(parseInt(c[0]),parseInt(c[1]),parseInt(c[2]),parseInt(c[3]),parseInt(c[4]),parseInt(c[5])); //截止时间
var NowTime = new Date();
var t = EndTime.getTime() - NowTime.getTime();
var h = Math.floor(t / 1000 / 60 / 60 % 24);
var m = Math.floor(t / 1000 / 60 % 60);
var s = Math.floor(t / 1000 % 60);
console.log('{$time}')
console.log(end)
if(EndTime > NowTime) {
if(h < 10) {
document.getElementById("t_h").innerHTML = "0" + h;
} else {
document.getElementById("t_h").innerHTML = h;
}
if(m < 10) {
document.getElementById("t_m").innerHTML = "0" + m;
} else {
document.getElementById("t_m").innerHTML = m;
}
if(s < 10) {
document.getElementById("t_s").innerHTML = "0" + s;
} else {
document.getElementById("t_s").innerHTML = s;
}
} else {
document.getElementById("t_h").innerHTML = "00";
document.getElementById("t_m").innerHTML = "00";
document.getElementById("t_s").innerHTML = "00";
}
}
setInterval(getRTime, 1000);
</script>
总结:如果只有ios端倒计时没有反应 一般问题就是 var EndTime = new Date( )中的参数问题 应该都是 number类型可解决此类问题