Jquery之倒計時計算
阿新 • • 發佈:2018-08-23
nbsp .get pre cti day gets minute spa jquer
1 setInterval("setDate(‘2018-12-24 12:20:45‘)",1000); 2 3 function setDate(setTime){ 4 var date = new Date();//獲取系統當前時間 5 var time = (date.getYear()+1900)+"-"+(date.getMonth()+1)+"-"+date.getDate() +" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); 6 var setDate = new Date(setTime);7 var leftTime = setDate.getTime()- date.getTime(); 8 /* 9 10 var Day = parseInt(dg/86400000); 11 var hg = dg - Day*86400000; 12 var Hours = parseInt(hg/3600000);; 13 var mg = hg - Hours*3600000; 14 var Minutes = parseInt(mg/60000); 15 var sg = mg - Minutes*60000; 16 var s = parseInt(sg/1000); 17 var dTime = Day + " 天 "+Hours + " 時 "+Minutes + " 分 "+s + " 秒 ";*/ 18 19 var d,h,m,s; 20 if (leftTime>=0) { 21 d = Math.floor(leftTime/1000/60/60/24); 22 h = Math.floor(leftTime/1000/60/60%24); 23 m = Math.floor(leftTime/1000/60%60); 24 s = Math.floor(leftTime/1000%60); 25 } 26 var dTime = d + " 天 "+h + " 時 "+m + " 分 "+s + " 秒 "; 27 28 29 //$("#time").html("倒計時:"+dTime); 30 }
Jquery之倒計時計算