计算机当前时间

2019-09-11 20:25:47 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>更新</title>
</head>
<body>
	<div id='timeShow'></div>
</body>
<script>
	var t = null;
	function time(){
 dt = new Date();
 var y = dt.getFullYear();
 var h = dt.getHours();
 var m = dt.getMinutes();
 var s = dt.getSeconds();
 document.getElementById("timeShow").innerHTML="当前时间:" y "年" h "时" m "分" s "秒";
 t = setTimeout(time,1000);    
} 
window.onload=function(){time()}
</script>
</html>

0 人点赞