获取当前时间(js)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="./js/jquery-1.10.2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="show">111</div>
<script>
$(function(){
var odiv = document.getElementById("show");
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth();
var data= date.getDate();
var hours=date.getHours();
var minute=date.getMinutes();
var second=date.getSeconds();
var time = year + "-" + fnW((month + 1)) + "-" + fnW(data) + " "
+ fnW(hours) + ":" + fnW(minute) + ":" + fnW(second);
odiv.innerHTML=time;
})
function fnW(str) {
var num;
str >= 10 ? num = str : num = "0" + str;
return num;
}
</script>
</body>
</html>