javascript代码:
<div id=watch></div>
<script language=javascript>
function watch()
{
var nowtime=new Date();
var watch="";
watch+=nowtime.getFullYear();
watch+=(nowtime.getMonth()<10)?"-0"+nowtime.getMonth():"-"+nowtime.getMonth();
watch+=(nowtime.getDate()<10)?"-0"+nowtime.getDate():"-"+nowtime.getDate();
watch+=(nowtime.getHours()<10)?" 0"+nowtime.getHours():" "+nowtime.getHours();
watch+=(nowtime.getMinutes()<10)?":0"+nowtime.getMinutes():":"+nowtime.getMinutes();
watch+=(nowtime.getSeconds()<10)?":0"+nowtime.getSeconds():":"+nowtime.getSeconds();
document.all.watch.innerText=watch;
}
setInterval("watch()",1);
</script>
其他的辅助功能自己加上去吧
<div id=watch></div>
<script language=javascript>
function watch()
{
var nowtime=new Date();
var watch="";
watch+=nowtime.getFullYear();
watch+=(nowtime.getMonth()<10)?"-0"+nowtime.getMonth():"-"+nowtime.getMonth();
watch+=(nowtime.getDate()<10)?"-0"+nowtime.getDate():"-"+nowtime.getDate();
watch+=(nowtime.getHours()<10)?" 0"+nowtime.getHours():" "+nowtime.getHours();
watch+=(nowtime.getMinutes()<10)?":0"+nowtime.getMinutes():":"+nowtime.getMinutes();
watch+=(nowtime.getSeconds()<10)?":0"+nowtime.getSeconds():":"+nowtime.getSeconds();
document.all.watch.innerText=watch;
}
setInterval("watch()",1);
</script>
其他的辅助功能自己加上去吧
<SCRIPT LANGUAGE="JavaScript">
<!--
var D1=null;
var D2=null;
var space_time=null;
function begin(){
D1=new Date();
}
function end(){
D2=new Date();
}
function check_space(){
space_time=(D2.getTime() - D1.getTime())/1000;
alert(space_time+"秒");
//这里可以放上表单提交的代码。
}
//-->
</SCRIPT>
<INPUT TYPE="button" value="begin" onclick="begin()"> <INPUT TYPE="button" value="end" onclick="end()">
<INPUT TYPE="button" value="check_space" onclick="check_space()">