1<SCRIPT LANGUAGE="JavaScript">
2<!--
3var maxtime = 60*60 //一个小时,按秒计算,自己调整!
4function CountDown(){
5 if(maxtime>=0){
6 minutes = Math.floor(maxtime/60);
7 seconds = Math.floor(maxtime%60);
8 msg = "距离结束还有"+minutes+"分"+seconds+"秒";
9 document.all["timer"].innerHTML=msg;
10 if(maxtime == 5*60) alert('注意,还有5分钟!');
11 --maxtime;
12 }
13 else{
14 clearInterval(timer);
15 alert("时间到,结束!");
16 }
17}
18timer = setInterval("CountDown()",1000);
19//-->
20</SCRIPT>
21<div id="timer" style="color:red"></div>
1<!--倒计时Javascript begin-->
2 <script language="JavaScript">
3 <!--
4 function DigitalTime1()
5 {
6 var deadline= new Date("08/13/2007") //开幕倒计时
7 var symbol="8月13日"
8 var now = new Date()
9 var diff = -480 - now.getTimezoneOffset() //是北京时间和当地时间的时间差
10 var leave = (deadline.getTime() - now.getTime()) + diff*60000
11 var day = Math.floor(leave / (1000 * 60 * 60 * 24))
12 var hour = Math.floor(leave / (1000*3600)) - (day * 24)
13 var minute = Math.floor(leave / (1000*60)) - (day * 24 *60) - (hour * 60)
14 var second = Math.floor(leave / (1000)) - (day * 24 *60*60) - (hour * 60 * 60) - (minute*60)
15
16 var deadline_2= new Date("08/13/2004") //开幕后计时
17 var symbol_2="8月13日"
18 var now_2 = new Date()
19 var diff_2 = -480 - now.getTimezoneOffset() //是北京时间和当地时间的时间差
20 var leave_2 = (now_2.getTime() - deadline_2.getTime()) + diff_2*60000
21 var day_2 = Math.floor(leave_2 / (1000 * 60 * 60 * 24))
22 var hour_2 = Math.floor(leave_2 / (1000*3600)) - (day_2 * 24)
23 var minute_2 = Math.floor(leave_2 / (1000*60)) - (day_2 * 24 *60) - (hour_2 * 60)
24 var second_2 = Math.floor(leave_2 / (1000)) - (day_2 * 24 *60*60) - (hour_2 * 60 * 60) - (minute_2*60)
25
26 day=day+1;
27 day_2=day_2+1;
28
29 if (day>0) //还未开幕
30 {
31 //LiveClock1.innerHTML = "现在"+symbol+"天"
32 LiveClock1.innerHTML = "<font class=fon1>距离"+symbol+"开幕还有<font class=fon2>"+day+"</font>天</font>"
33 setTimeout("DigitalTime1()",1000)
34 }
35
36 if (day<0) //已经开幕
37 {
38 //LiveClock1.innerHTML = "现在离"+symbol+"还有"+day+"天"+hour+"小时"+minute+"分"+second +"秒"
39 LiveClock1.innerHTML = "<font class=fon1>"+symbol+"开幕已有<font class=fon2>"+day_2+"</font>天</font>"
40 setTimeout("DigitalTime1()",1000)
41
42 }
43
44 if (day==0) //正在开幕
45 {
46 //LiveClock1.innerHTML = "现在"+symbol+"天"
47 LiveClock1.innerHTML = "<font class=fon1>某某运动会今天开幕</font>"
48 setTimeout("DigitalTime1()",1000)
49 }
50
51
52
53 if (day<0 & day_2>19) //某某运动会结束
54 {
55 //LiveClock1.innerHTML = "现在离"+symbol+"还有"+day+"天"+hour+"小时"+minute+"分"+second +"秒"
56 LiveClock1.innerHTML = "<font class=fon1>某某运动会已全部结束</font>"
57 setTimeout("DigitalTime1()",1000)
58
59 }
60
61 }
62 // -->
63 </script>
64 <!--倒计时Javascript end-->
65<body onload=DigitalTime1()>
66<div id= LiveClock1></div>
67
68</body>
2 <script language="JavaScript">
3 <!--
4 function DigitalTime1()
5 {
6 var deadline= new Date("08/13/2007") //开幕倒计时
7 var symbol="8月13日"
8 var now = new Date()
9 var diff = -480 - now.getTimezoneOffset() //是北京时间和当地时间的时间差
10 var leave = (deadline.getTime() - now.getTime()) + diff*60000
11 var day = Math.floor(leave / (1000 * 60 * 60 * 24))
12 var hour = Math.floor(leave / (1000*3600)) - (day * 24)
13 var minute = Math.floor(leave / (1000*60)) - (day * 24 *60) - (hour * 60)
14 var second = Math.floor(leave / (1000)) - (day * 24 *60*60) - (hour * 60 * 60) - (minute*60)
15
16 var deadline_2= new Date("08/13/2004") //开幕后计时
17 var symbol_2="8月13日"
18 var now_2 = new Date()
19 var diff_2 = -480 - now.getTimezoneOffset() //是北京时间和当地时间的时间差
20 var leave_2 = (now_2.getTime() - deadline_2.getTime()) + diff_2*60000
21 var day_2 = Math.floor(leave_2 / (1000 * 60 * 60 * 24))
22 var hour_2 = Math.floor(leave_2 / (1000*3600)) - (day_2 * 24)
23 var minute_2 = Math.floor(leave_2 / (1000*60)) - (day_2 * 24 *60) - (hour_2 * 60)
24 var second_2 = Math.floor(leave_2 / (1000)) - (day_2 * 24 *60*60) - (hour_2 * 60 * 60) - (minute_2*60)
25
26 day=day+1;
27 day_2=day_2+1;
28
29 if (day>0) //还未开幕
30 {
31 //LiveClock1.innerHTML = "现在"+symbol+"天"
32 LiveClock1.innerHTML = "<font class=fon1>距离"+symbol+"开幕还有<font class=fon2>"+day+"</font>天</font>"
33 setTimeout("DigitalTime1()",1000)
34 }
35
36 if (day<0) //已经开幕
37 {
38 //LiveClock1.innerHTML = "现在离"+symbol+"还有"+day+"天"+hour+"小时"+minute+"分"+second +"秒"
39 LiveClock1.innerHTML = "<font class=fon1>"+symbol+"开幕已有<font class=fon2>"+day_2+"</font>天</font>"
40 setTimeout("DigitalTime1()",1000)
41
42 }
43
44 if (day==0) //正在开幕
45 {
46 //LiveClock1.innerHTML = "现在"+symbol+"天"
47 LiveClock1.innerHTML = "<font class=fon1>某某运动会今天开幕</font>"
48 setTimeout("DigitalTime1()",1000)
49 }
50
51
52
53 if (day<0 & day_2>19) //某某运动会结束
54 {
55 //LiveClock1.innerHTML = "现在离"+symbol+"还有"+day+"天"+hour+"小时"+minute+"分"+second +"秒"
56 LiveClock1.innerHTML = "<font class=fon1>某某运动会已全部结束</font>"
57 setTimeout("DigitalTime1()",1000)
58
59 }
60
61 }
62 // -->
63 </script>
64 <!--倒计时Javascript end-->
65<body onload=DigitalTime1()>
66<div id= LiveClock1></div>
67
68</body>
1<Script Language="JavaScript">
2<!-- Begin
3 var timedate= new Date("January 14,2006");
4 var times="研究生考试";
5 var now = new Date();
6 var date = timedate.getTime() - now.getTime();
7 var time = Math.floor(date / (1000 * 60 * 60 * 24));
8 if (time >= 0) ;
9document.write("<li><font color=#DEDBDE>现在离2006年"+times+"还有: <font color=#ffffff><b>"+time +"</b></font> 天</font></li>");
10// End -->
11</Script>
2<!-- Begin
3 var timedate= new Date("January 14,2006");
4 var times="研究生考试";
5 var now = new Date();
6 var date = timedate.getTime() - now.getTime();
7 var time = Math.floor(date / (1000 * 60 * 60 * 24));
8 if (time >= 0) ;
9document.write("<li><font color=#DEDBDE>现在离2006年"+times+"还有: <font color=#ffffff><b>"+time +"</b></font> 天</font></li>");
10// End -->
11</Script>
1<form name="form1">
2<div align="center" align="middle">
3<center>离2010年还有:<br>
4<input type="textarea" name="left" size="35" style="text-align: center">
5</center>
6</div>
7</form>
8<script LANGUAGE="javascript">
9startclock()
10var timerID = null;
11var timerRunning = false;
12function showtime() {
13Today = new Date();
14var NowHour = Today.getHours();
15var NowMinute = Today.getMinutes();
16var NowMonth = Today.getMonth();
17var NowDate = Today.getDate();
18var NowYear = Today.getYear();
19var NowSecond = Today.getSeconds();
20if (NowYear <2000)
21NowYear=1900+NowYear;
22Today = null;
23Hourleft = 23 - NowHour
24Minuteleft = 59 - NowMinute
25Secondleft = 59 - NowSecond
26Yearleft = 2009 - NowYear
27Monthleft = 12 - NowMonth - 1
28Dateleft = 31 - NowDate
29if (Secondleft<0)
30{
31Secondleft=60+Secondleft;
32Minuteleft=Minuteleft-1;
33}
34if (Minuteleft<0)
35{
36Minuteleft=60+Minuteleft;
37Hourleft=Hourleft-1;
38}
39if (Hourleft<0)
40{
41Hourleft=24+Hourleft;
42Dateleft=Dateleft-1;
43}
44if (Dateleft<0)
45{
46Dateleft=31+Dateleft;
47Monthleft=Monthleft-1;
48}
49if (Monthleft<0)
50{
51Monthleft=12+Monthleft;
52Yearleft=Yearleft-1;
53}
54Temp=Yearleft+'年, '+Monthleft+'月, '+Dateleft+'天, '+Hourleft+'小时, '+Minuteleft+'分, '+Secondleft+'秒'
55document.form1.left.value=Temp;
56timerID = setTimeout("showtime()",1000);
57timerRunning = true;
58}
59var timerID = null;
60var timerRunning = false;
61function stopclock () {
62if(timerRunning)
63clearTimeout(timerID);
64timerRunning = false;
65}
66function startclock () {
67stopclock();
68showtime();
69}
70// -->
71</script>
2<div align="center" align="middle">
3<center>离2010年还有:<br>
4<input type="textarea" name="left" size="35" style="text-align: center">
5</center>
6</div>
7</form>
8<script LANGUAGE="javascript">
9startclock()
10var timerID = null;
11var timerRunning = false;
12function showtime() {
13Today = new Date();
14var NowHour = Today.getHours();
15var NowMinute = Today.getMinutes();
16var NowMonth = Today.getMonth();
17var NowDate = Today.getDate();
18var NowYear = Today.getYear();
19var NowSecond = Today.getSeconds();
20if (NowYear <2000)
21NowYear=1900+NowYear;
22Today = null;
23Hourleft = 23 - NowHour
24Minuteleft = 59 - NowMinute
25Secondleft = 59 - NowSecond
26Yearleft = 2009 - NowYear
27Monthleft = 12 - NowMonth - 1
28Dateleft = 31 - NowDate
29if (Secondleft<0)
30{
31Secondleft=60+Secondleft;
32Minuteleft=Minuteleft-1;
33}
34if (Minuteleft<0)
35{
36Minuteleft=60+Minuteleft;
37Hourleft=Hourleft-1;
38}
39if (Hourleft<0)
40{
41Hourleft=24+Hourleft;
42Dateleft=Dateleft-1;
43}
44if (Dateleft<0)
45{
46Dateleft=31+Dateleft;
47Monthleft=Monthleft-1;
48}
49if (Monthleft<0)
50{
51Monthleft=12+Monthleft;
52Yearleft=Yearleft-1;
53}
54Temp=Yearleft+'年, '+Monthleft+'月, '+Dateleft+'天, '+Hourleft+'小时, '+Minuteleft+'分, '+Secondleft+'秒'
55document.form1.left.value=Temp;
56timerID = setTimeout("showtime()",1000);
57timerRunning = true;
58}
59var timerID = null;
60var timerRunning = false;
61function stopclock () {
62if(timerRunning)
63clearTimeout(timerID);
64timerRunning = false;
65}
66function startclock () {
67stopclock();
68showtime();
69}
70// -->
71</script>
来源:https://www.cnblogs.com/rainyfox/archive/2007/01/11/617605.html