标签:new span date() bsp var pre title eth amp
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<span id="span"></span>
</body>
</html>
<script>
var span = document.getElementById("span");
function time_get() {
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth() + 1;
var day = time.getDay();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds()<10?"0"+time.getSeconds():time.getSeconds();
var time_str = year + "-" + month + "-" +
day + " " + hour + ":" +
minute + ":" + second;
span.innerHTML = time_str;
}
window.setInterval("time_get()",500);
</script>
标签:new span date() bsp var pre title eth amp
原文地址:http://www.cnblogs.com/yangchuanqi/p/7613245.html