首页 > 代码库 > 获取系统时间

获取系统时间

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
div{width:420px;height:200px;}
#box{background:blue;}
div span{color:#ffcc00; }
#submit{width:40px;}
</style>
<head>
<script type="text/javascript">
var WeekName=[ "日", "一","二","三","四","五","六",];
window.onload=function()
{

var oBox = document.getElementById(‘box2‘);
var oSubmit = document.getElementById(‘submit‘);
var str; updatetime();

function updatetime(){

var oDate = new Date();
str = oDate.getFullYear()+‘年‘+(oDate.getMonth()<=9?‘0‘:‘‘)+(oDate.getMonth()+1)+‘月‘+(oDate.getDate()<=9?‘0‘:‘‘)+oDate.getDate()+‘日‘;
str = str+(oDate.getHours()<=9?‘0‘:‘‘)+oDate.getHours()+‘时‘+(oDate.getMinutes()<=9?‘0‘:‘‘)+oDate.getMinutes()+‘分‘;
str = str+(oDate.getSeconds()<=9?‘0‘:‘‘)+oDate.getSeconds()+‘秒‘;
str = str+‘ ‘+‘星期‘+WeekName[(oDate.getDay())]
oBox.innerHTML = str;str = ‘‘;

var a = setInterval(updatetime,1000);

}

};

</script>
</head>

<body>
<div id = "box2">
</div>

</body>

</html>

获取系统时间