<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<span id="span"></span>
</body>
<script type="text/javascript">
function get_time(){
var date=new Date();//创建日期对象
var time=date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"+date.getHours()+"时"+date.getMinutes()+"分"+date.getSeconds()+"秒";
var obj=document.getElementById("span");//获取span对象
obj.innerHTML=time.fontcolor("red");//将time写入到span标签中,修改时间颜色
}
window.setInterval("get_time()",1000);//定时器
</script>
</html>