网页关于时间的代码! 中高手进~~
发布网友
发布时间:2022-05-17 18:43
我来回答
共1个回答
热心网友
时间:2023-08-14 07:43
不用下载http://time.tv.cctv.com/OlympicTime/time1.jsp!直接将下列代码保存于本地计算机中运行即可。
<html>
<head>
<title>标题</title>
</head>
<body>
<div class="top-col-3">
<div id="wch-countdown">
<div class="wch-countdown">
<font color="#FFFF00">
<span>汶川地震发生至今</span>
<script language=Javascript>
var now = new Date()
function time(){
var now_start1= new Date("05/12/2008 14:28:00");
now.setTime(now.getTime()+250);
//alert(now_start1 - now);
day1 = Math.floor((now - now_start1) / 1000 / 60 / 60 / 24);
hour1 = Math.floor((now - now_start1) / 1000 / 60 / 60 - (24 * day1));
minute1 = Math.floor((now - now_start1) / 1000 /60 - (24 * 60 * day1) - (60 * hour1));
second1 = Math.round((now - now_start1) / 1000 - (24 * 60 * 60 * day1) - (60 * 60 * hour1) - (60 * minute1));
if(day1<10) day1 = "0" + day1;
if(hour1<10) hour1 = "0" + hour1;
if(hour1==24) hour1 = 23;
if(minute1<10) minute1 = "0" + minute1;
if(minute1==60) minute1 = 59;
if(second1<10) second1 = "0" + second1;
if(second1==60) second1 = 59;
str01 = "<b id=wch-countdown-d>"+day1+"</b><span>天</span><b id=wch-countdown-h>"+hour1+"</b><span>小时</span><b id=wch-
countdown-m>"+minute1+"</b><span>分</span><b id=wch-countdown-s>"+second1+"</b><span>秒</span>";
document.getElementById("time").innerHTML = str01;
}
setInterval("time()",250);
//time();
</script>
</font>
<div id="time"></div>
</div>
</div>
</body>
</html>