1. 程式人生 > >獲取系統當前的時間,並且在span中顯示出來

獲取系統當前的時間,並且在span中顯示出來

<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<span id="span"></span>
		<script type="text/javascript">
			function fun(){
				var date=new Date();
				document.getElementById("span").innerHTML=(1900+date.getYear())+"年"+(date.getMonth()+1)+"月"+date.getDay()+"日"+date.getHours()+"時"+date.getMinutes()+"分"+date.getSeconds()+"秒"
			}
			setInterval(fun,1000)
		</script>
	</body>
</html>

輸出圖片如下: