js團購倒計時


function FreshTime()
{
        var endtime=new Date("2014/5/15,12:20:12");//結束時間
        var nowtime = new Date();//當前時間
        var lefttime=parseInt((endtime.getTime()-nowtime.getTime())/1000);
        d=parseInt(lefttime/3600/24);
        h=parseInt((lefttime/3600)%24);
        m=parseInt((lefttime/60)%60);
        s=parseInt(lefttime%60);
       
        document.getElementById("LeftTime").innerHTML=d+"天"+h+"小時"+m+"分"+s+"秒";
        if(lefttime<=0){
        document.getElementById("LeftTime").innerHTML="團購已結束";
        clearInterval(sh);
        }
}
FreshTime()
var sh;
sh=setInterval(FreshTime,1000);

get

相關文章
相關標籤/搜索