JS计时在IE里显示NaN,怎么解决,下面是代码
functiontimeElapse(c){varod=newDate("2009-02-1413:14:10");vartd=newDate();varcd=td.ge...
function timeElapse(c) {
var od = new Date("2009-02-14 13:14:10");
var td = new Date();
var cd = td.getTime() - od.getTime();
var days = Math.floor(cd / (24 * 3600 * 1e3));
var leave1 = cd % (24 * 3600 * 1e3);
var hours = Math.floor(leave1 / (3600 * 1e3));
var leave2 = leave1 % (3600 * 1e3);
var minutes = Math.floor(leave2 / (60 * 1e3));
var leave3 = leave2 % (60 * 1e3);
var seconds = Math.round(leave3 / 1e3);
var e = Date();
var f = (Date.parse(e) - Date.parse(c)) / 1e3;
var g = Math.floor(f / (3600 * 24)) + days;
f = f % (3600 * 24);
var b = Math.floor(f / 3600) + hours;
if (b < 10) {
b = "0" + b;
}
f = f % 3600;
var d = Math.floor(f / 60) + minutes;
if (d < 10) {
d = "0" + d;
}
f = (f + seconds) % 60;
if (f < 10) {
f = "0" + f;
}
var a = '<span class="digit">' + g + '</span> days <span class="digit">' + b + '</span> hours <span class="digit">' + d + '</span> minutes <span class="digit">' + f + "</span> seconds";
$("#elapseClock").html(a); 展开
var od = new Date("2009-02-14 13:14:10");
var td = new Date();
var cd = td.getTime() - od.getTime();
var days = Math.floor(cd / (24 * 3600 * 1e3));
var leave1 = cd % (24 * 3600 * 1e3);
var hours = Math.floor(leave1 / (3600 * 1e3));
var leave2 = leave1 % (3600 * 1e3);
var minutes = Math.floor(leave2 / (60 * 1e3));
var leave3 = leave2 % (60 * 1e3);
var seconds = Math.round(leave3 / 1e3);
var e = Date();
var f = (Date.parse(e) - Date.parse(c)) / 1e3;
var g = Math.floor(f / (3600 * 24)) + days;
f = f % (3600 * 24);
var b = Math.floor(f / 3600) + hours;
if (b < 10) {
b = "0" + b;
}
f = f % 3600;
var d = Math.floor(f / 60) + minutes;
if (d < 10) {
d = "0" + d;
}
f = (f + seconds) % 60;
if (f < 10) {
f = "0" + f;
}
var a = '<span class="digit">' + g + '</span> days <span class="digit">' + b + '</span> hours <span class="digit">' + d + '</span> minutes <span class="digit">' + f + "</span> seconds";
$("#elapseClock").html(a); 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询