记住--前端页面实时显示系统当前时间

<html>
<head>
<meta charset="utf-8">
<script>
function settime(  )
{
var date=new Date();

var year=date.getFullYear();
var month=date.getMonth()+1;
month=month<10?('0'+month):month;
var day=date.getDate();
day=day<10?('0'+day):day
var hour=date.getHours();
hour=hour<10?('0'+hour):hour;
var minute=date.getMinutes();
minute=minute<10?('0'+minute):minute;
var second=date.getSeconds();
second=second<10?('0'+second):second;
document.getElementById("nowtime").innerText=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
setTimeout("settime()",1000);
}
</script>
</head>
<body onload="settime()">
	<div id="nowtime">
	</div>
</body>
</html>

你可能感兴趣的:(需要记住的程序)