点击获取当前时间
7202019-04-12 18:14:13390<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
div{ width: 300px; height: 60px; border-bottom: 1px solid red; line-height: 60px; }
input{ border: none; width:120px; height:40px; background: #ffa200; color: #fff; text-align: center; line-height: 40px; font-size: 14px; margin-top: 30px;}
</style>
</head>
<body>
<div id="myDiv"></div>
<input id="btn" type="button" value="获取当前时间" onclick="btn(this)">
<script type="text/javascript">
function btn(x){
var myDiv= document.getElementById("myDiv");
var myday=new Date();
var month = new Array(12);
month[0]="1";
month[1]="2";
month[2]="3";
month[3]="4";
month[4]="5";
month[5]="6";
month[6]="7";
month[7]="8";
month[8]="9";
month[9]="10";
month[10]="11";
month[11]="12";
myDiv.innerHTML = myday.getFullYear() + '年' + month[myday.getMonth()] + '月' + myday.getDate() + '日' + myday.getHours() + '时' + myday.getMinutes() + '分' + myday.getSeconds() + '秒' + '星期' + myday.getDay();
}
</script>
</body>
</html>