javascript得到动态时间

 

<script language="javascript" type="text/javascript">
  function window_onload()
  {
   window.setTimeout("dispgettime()",1000);
   var outDate=new Date();
   labOver.innerText=outDate.getFullYear()+"年"
   +(outDate.getMonth()+1)+"月"+outDate.getDate()+"日 "
  }
  function gettime()
  {
   var d=new Date();
   return d.getHours()+"时"+d.getMinutes()+"分"+d.getSeconds()+"秒";
  }
  </script>
  <script language="vbs">
  
  startTime="22:48:19"
  
  function dispgettime()
   tt=DateDiff("s",startTime,gettime())
   //labOver.innerText=Int(tt/60/60)&":"& Int(tt/60) mod 60 &":"& tt mod 60
   labTime.innerText=gettime()
   window.setTimeout "dispgettime()",1000
  end function
  </script>
<body onLoad="window_onload()">
    <form id="form1" runat="server">
    <div>
    <LABEL id="labOver"></LABEL><br />
    <LABEL id="labTime"></LABEL>
    </div>
    </form>
</body>

 

 

 

 

 

 

 

 

<script language="JavaScript" type="text/javascript">
<!--
document.write("<span id='clock'></span>");
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
var monthname =
new Array ("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月" );
document.write(year +"年");
document.write(monthname[month]);
document.write(date + "日"+" ");
showtime();
var now,hours,minutes,seconds,timeValue;
function showtime(){
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? " 下午 " : " 上午 ";
timeValue += ((hours > 12) ? hours - 12 : hours) + "点";
timeValue += ((minutes <10)?"0":"") + minutes+"分";
timeValue += ((seconds <10)?"0":"") + seconds+"秒";
clock.innerHTML = timeValue;
setTimeout("showtime()",100);
}
//-->
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值