<html> <head> <title>THE DATE AND TIMES TEST </title> <script language="javascript" type="text/javascript"> ID=window.setTimeout("update();",2000); function update() { now=new Date(); hours=now.getHours(); minu=now.getminutes(); secs=now.getSeconds();
ID=window.setTimeout("update();",2000); } document.write(hours+":"+minu+":"+secs); </script> </head> <body> <h1>Current times and Dates </h1> <input type="button" value="reload" onClick="update();"> </body> </html>
<script type="text/javascript"> <!-- function refreshCalendarClock(){ document.getElementById("showclock").innerHTML=thisYear()+Year_Month()+Date_of_Today()+Day_of_Today()+CurentTime(); } function thisYear(){ var now = new Date(); var yy = now.getFullYear()+"年"; return(yy ); } function Year_Month(){ var now = new Date(); now.toTimeString(); var mm = (now.getMonth()+1)+"月"; return(mm ); } function Date_of_Today(){ var now = new Date(); return(now.getDate()+"日" ); } function Day_of_Today(){ var now=new Date(); var week=new Array(" 星期日 "," 星期一 "," 星期二 "," 星期三 "," 星期四 "," 星期五 "," 星期六 "); return(week[now.getDay()]);} function CurentTime(){ var now = new Date(); var hh = now.getHours(); var mm = now.getMinutes(); var ss = now.getTime() % 60000; ss = (ss - (ss % 1000)) / 1000; var clock = hh+':'; if (mm < 10) clock += '0'; clock += mm+':'; if (ss < 10) clock += '0'; clock += ss; return(clock); } setInterval('refreshCalendarClock()',1000); //--> </script> 显示用 <div id="showclock"> </div>或span