<script type="text/javascript">
function getDate(){
var mydate = new Date(); //时间对象
var year=mydate.getFullYear(); //年
var month=mydate.getMonth()+1; //月
var date=mydate.getDate(); //日
var day=mydate.getDay(); //星期几
var hour=mydate.getHours(); //小时
if (hour<10) {
hour='0'+hour;
}
var minute=mydate.getMinutes(); //分钟
if (minute<10) {
minute='0'+minute;
}
var second=mydate.getSeconds(); //秒
if (second<10) {
second='0'+second;
}
//str = year+'-'+month+'-'+date+' '+hour+':'+minute+':'+second;
str = hour+':'+minute+':'+second;
tiobj = document.getElementById("ti");
tiobj.innerHTML=str;
}
getDate(); //先获取一次时间,然后再没秒刷新
setInterval(getDate,1000);
</script>