标题:如何把倒计时的代码“时,分,秒”修改成“天,时,分,秒”,感谢!
只看楼主
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
结帖率:87.5%
已结贴  问题点数:20 回复次数:3 
如何把倒计时的代码“时,分,秒”修改成“天,时,分,秒”,感谢!
一个网页多个倒计时的JS代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>倒计时</title>
</head>
<script language=JavaScript>
var endtimes=new Array();//结束时间
endtimes[0]="4/6/2010 9:03:00";
endtimes[1]="4/6/2010 9:04:20";
endtimes[2]="4/8/2010 9:05:00";
endtimes[3]="4/9/2010 9:05:00";
var nowtimes;
function givetime(){
 nowtimes=new Date("4/6/2010 9:03:00");//当前服务器时间
 window.setTimeout("DownCount()",1000)
}
function DownCount(){
 nowtimes=Number(nowtimes)+1000;
 for(var i=0;i<=3;i++)
 {
  var theDay=new Date(endtimes[i]);
  theDay=theDay++;
  if(theDay<=nowtimes)
  {
   document.getElementById("times"+i).innerHTML = "00小时,00分钟,00秒";
  }
  else{
    timechange(theDay,i);
   
  }
 }
 window.setTimeout("DownCount()",1000)
}
function timechange(theDay,i){
 var theDays=new Date(theDay);
 var seconds = (theDays - nowtimes)/1000;
 var minutes = Math.floor(seconds/60);
 var hours = Math.floor(minutes/60);
 var days = Math.floor(hours/24);
 var CDay= days;
 var CHour= hours % 24;
 var CMinute= minutes % 60;
 var CSecond= seconds % 60;
 var CHour=CHour+CDay*24;
 if(CMinute<10)
 {
  CMinute="0"+CMinute;
 }
 if(CHour<10)
 {
  CHour="0"+CHour;
 }
 if(CSecond<10)
 {
  CSecond="0"+CSecond;
 }
 document.getElementById("times"+i).innerHTML = CHour + "小时," + CMinute + "分钟," + CSecond + "秒";
}
</script>
<BODY onload="givetime()">
<table border="0" cellSpacing="0" cellPadding="0" width="100%" align="center" style="font-size:9pt">
<tr><td align="center">
距亚运会开幕还有:<div id="times0"></div>
<div id="times1"></div>
<div id="times2"></div>
<div id="times3"></div>
</td></tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: html content PUBLIC title 如何 
2012-01-30 23:35
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
得分:0 
急啊,帮帮我吧!
急啊,帮帮我吧!
2012-01-31 15:59
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:20 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>倒计时</title>
</head>
<script language=JavaScript>
var endtimes=new Array();//结束时间
endtimes[0]="4/6/2010 9:03:00";
endtimes[1]="4/6/2010 9:04:20";
endtimes[2]="4/8/2010 9:05:00";
endtimes[3]="4/9/2010 9:05:00";
var nowtimes;
function givetime(){
nowtimes=new Date("4/6/2010 9:03:00");//当前服务器时间
window.setTimeout("DownCount()",1000)
}
function DownCount(){
nowtimes=Number(nowtimes)+1000;
for(var i=0;i<=3;i++)
{
  var theDay=new Date(endtimes[i]);
  theDay=theDay++;
  if(theDay<=nowtimes)
  {
   document.getElementById("times"+i).innerHTML = "0天,00小时,00分钟,00秒";
  }
  else{
    timechange(theDay,i);
   
  }
}
window.setTimeout("DownCount()",1000)
}
function timechange(theDay,i){
var theDays=new Date(theDay);
var seconds = (theDays - nowtimes)/1000;
var minutes = Math.floor(seconds/60);
var hours = Math.floor(minutes/60);
var days = Math.floor(hours/24);
var CDay= days;
var CHour= hours % 24;
var CMinute= minutes % 60;
var CSecond= seconds % 60;
//var CHour=CHour+CDay*24;
if(CMinute<10)
{
  CMinute="0"+CMinute;
}
if(CHour<10)
{
  CHour="0"+CHour;
}
if(CSecond<10)
{
  CSecond="0"+CSecond;
}
document.getElementById("times"+i).innerHTML = CDay + "天," + CHour + "小时," + CMinute + "分钟," + CSecond + "秒";
}
</script>
<BODY onload="givetime()">
<table border="0" cellSpacing="0" cellPadding="0" width="100%" align="center" style="font-size:9pt">
<tr><td align="center">
距亚运会开幕还有:<div id="times0"></div>
<div id="times1"></div>
<div id="times2"></div>
<div id="times3"></div>
</td></tr>
</table>
</body>
</html>


QQ:63572063
2012-01-31 17:45
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
得分:0 
回复 3楼 wangjy500
谢谢,成功!
2012-01-31 22:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360159-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.807716 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved