码迷,mamicode.com
首页 > Web开发 > 详细

Jquery之倒计时计算

时间:2018-08-23 14:11:22      阅读:174      评论:0      收藏:0      [点我收藏+]

标签: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 }

 

 

Jquery之倒计时计算

标签:time()   set   floor   second   function   2-2   var   时间   interval   

原文地址:https://www.cnblogs.com/JoseCen/p/9523214.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!