CSDN博客

img net_spirit

用JAVASCIRPT写的一个动态显示日期的函数!

发表于2001/3/22 20:27:00  549人阅读

分类: javascript

<script language="JavaScript">
function showtime()
{
  var GetTime = new Date();
  var Years = GetTime.getYear();
  var Months = GetTime.getMonth();
  var Days = GetTime.getDate();
  var Hours = GetTime.getHours();
  var Minutes = GetTime.getMinutes();
  var Seconds = GetTime.getSeconds();
  var Dn = 'AM';
  if (Hours<=9)
    {
      Hours='0'+Hours;
    }
  if (Hours==0 || Hours>12)
    {
      Dn = 'PM';
    } 
  if (Minutes<=9)
    {
      Minutes='0'+Minutes;
    } 
  if (Seconds<=9)
    {
      Seconds='0'+Seconds;
    } 
   NowTime = Years+'年'+Months+'月'+Days+'日 '+Hours+':'+Minutes+':'+Seconds+' '+Dn;
   if (document.layers){
     document.layers.liveclock.document.write(NowTime)
     document.layers.liveclock.document.close()
   }
   else if (document.all)
     liveclock.innerHTML=NowTime
   setTimeout('showtime()',1000)
}
</script>
<table height=50 border=1 align=center width=200>
<tr>
<td bgcolor="#FFCC00" valign="middle">
<font size="2" face="Arial, Helvetica, sans-serif" color="black">
<DIV align=center id=liveclock></DIV></font></td>
</tr>
</table>

<script language="JavaScript">
   setTimeout('showtime()',1000)
</script>

0 0

相关博文

我的热门文章

img
取 消
img