求问:为什么我日期计算不正确,lefttime是正确的,到日期计算机错了?
//倒计时效果之限时抢购
function rob(){
var endtime = new Date("2016/4/10,10:00:00");
var nowtime = new Date();
var lefttime = parseInt((endtime.getTime()-nowtime.getTime())/1000);
var d = parseInt(lefttime/24*60*60),
h = parseInt(lefttime/(60*60)%24),
m = parseInt(lefttime/60%60),
s = parseInt(lefttime%60);
alert(lefttime);
alert(d);
document.getElementById("rob").innerHTML=d+"天"+h+"小时"+m+"分"
+s+"秒";
//setTimeout('rob()',500);
}
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload!="function"){
window.onload = func;
}else{
window.onload = function(){
oldonload();
func();
}
}
}
addLoadEvent(rob);