标签:time() set floor second function 2-2 var 时间 interval
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 }
标签:time() set floor second function 2-2 var 时间 interval
原文地址:https://www.cnblogs.com/JoseCen/p/9523214.html