1.客户机时间(简单)
<body>
<span id="aa1"> </span>
<script>
showTime();
function showTime(){
var now = new Date();
document.getElementById("aa1").innerHTML=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
setTimeout("showTime()",1000);
}
</script>
</body>
2.服务器时间(也不难)
<%@ page language="java" import="java.util.*" contentType="text/html;charset=GBK" %>
<html>
<body>
<span id="aa1"> </span>
<script>
var now = new Date();
now.setTime( <%=new Date().getTime()%>);
showTime();
function showTime(){
document.getElementById("aa1").innerHTML=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
var c=now.getTime();
c+=1000;
now.setTime(c);
setTimeout("showTime()",1000);
}
</script>
</body>
</html>
<body>
<span id="aa1"> </span>
<script>
showTime();
function showTime(){
var now = new Date();
document.getElementById("aa1").innerHTML=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
setTimeout("showTime()",1000);
}
</script>
</body>
2.服务器时间(也不难)
<%@ page language="java" import="java.util.*" contentType="text/html;charset=GBK" %>
<html>
<body>
<span id="aa1"> </span>
<script>
var now = new Date();
now.setTime( <%=new Date().getTime()%>);
showTime();
function showTime(){
document.getElementById("aa1").innerHTML=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
var c=now.getTime();
c+=1000;
now.setTime(c);
setTimeout("showTime()",1000);
}
</script>
</body>
</html>