close
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
			function showTime(){
				var today = new Date();
				var hour=
				parseInt(today.getHours())<10 
				? '0'+today.getHours() 
				: today.getHours();

				var min=
				parseInt(today.getMinutes())<10 
				? '0'+today.getMinutes() 
				: today.getMinutes();

				var sec=
				parseInt(today.getSeconds())<10 
				? '0'+today.getSeconds() 
				: today.getSeconds();

				document.getElementById('nowtime').innerHTML=hour+':'+min+':'+sec
			}
			window.onload=function(){
				setInterval(showTime,1000);
        		var today = new Date();
        		document.getElementById('nowdate').textContent=
          		today.getFullYear()+'/'+
          		(today.getMonth()+1)+'/'+
          		today.getDate()+'/'+
          		'星期'+today.getDay()
			}
			

	</script>
</head>
<body>
  <h2>現在日期:<span id="nowdate"></span></h2>
	<h2>現在時間:<span id="nowtime"></span></h2>
</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Jerry 的頭像
    Jerry

    Bug倉庫 // 程式日記

    Jerry 發表在 痞客邦 留言(0) 人氣()