码迷,mamicode.com
首页 > 其他好文 > 详细

倒计时原理

时间:2017-08-21 00:17:26      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:原理   script   字符   logs   doc   arc   cto   apr   参数   

 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 5 <title>无标题文档</title>
 6  
 7 <script>
 8 // 现在的时间点(在变)
 9 // 未来的时间点(不变)
10 var iNow = new Date();
11 var iNew = new Date( November 27,2013 22:3:0 );
12 var t = Math.floor((iNew - iNow)/1000);// 毫秒 -13 
14 var str = Math.floor(t/86400)+‘天‘+Math.floor(t%86400/3600)++Math.floor(t%86400%3600/60)+‘分‘+t%60+‘秒‘;
15  
16 alert( str );
17 
18 
19 
20 
21  //时间转换公式:
22 // 天:Math.floor(t/86400)
23 // 时:Math.floor(t%86400/3600)
24 // 分:Math.floor(t%86400%3600/60)
25 // 秒:t%60
26  
27 //date对象参数:
28 // 数字形式:new Date( 2013,4,1,9,48,12 );
29 // 字符串形式:new Date(‘June 10,2013 12:12:12‘);
30 
31 //月份取值:
32 // January、February、March、April、May、June、
33 // July、August、September、October、November、December
34 
35 //时间戳:getTime();
36 </script>
37  
38 </head>
39  
40 <body>
41 </body>
42 </html>

 

倒计时原理

标签:原理   script   字符   logs   doc   arc   cto   apr   参数   

原文地址:http://www.cnblogs.com/miaoxiaojiao/p/7401881.html

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