js获取是时间代码

 <script type="text/javascript" language="javascript">
var timer0 = null;
var week = new Array( "日", "一", "二", "三", "四", "五", "六" );
timer0 = setTimeout(showTime,1000);
function showTime()
{
   clearTimeout(timer0);
   dt = new Date();
   var weekday = week[dt.getDay()];
   var tp = document.getElementById("timePlace");
   result = dt.toLocaleDateString()+" 星期"+weekday;//+" "+dt.toLocaleTimeString();
   tp.innerHTML = result;
   timer0 = setTimeout(showTime,1000);             
}
   </script>
</head>

<body>
<span id="timePlace"></span>

你可能感兴趣的:(js)