方法1:js脚本
当前时间:
<span id=name1></span>
<script type="text/javascript">
function gettime()
{ var t = new Date();
var years = t.getFullYear();
var months = t.getMonth();
var days = t.getDay();
var hours = t.getHours();
var minutes = t.getMinutes();
var seconds = t.getSeconds();
var show_str ="服务器时间:";
show_str += (years+"-"+months+"-"+days+" "+hours);
show_str += ((minutes <10) ? ":0" : ":") + minutes;
show_str += ((seconds <10) ? ":0" : ":") + seconds;
name1.innerText = show_str;
timerID = setTimeout("gettime()",1000);
}
</script>
方法2:js脚本
<div id="time">
<script>
document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());
setInterval("document.getElementById('time').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
</script>
</div>
方法3:暂放着