小程序,用js获取当前系统时间并显示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
//Math对象的使用
//alert(Math.PI);
/*alert(Math.random());
alert(Math.max(5,9,78,65,23,45));
alert(Math.min(5,9,78,65,23,45));*/
//Date对象的是使用
function sysTime(){
var now=new Date();
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=now.getDate();
var day=now.getDay();
var hour=now.getHours();
var minutes=now.getMinutes();
var sec=now.getSeconds();
var arr_week=new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
var week=arr_week[day];
var time=year+"年"+month+"月"+date+"日"+hour+":"+minutes+":"+sec+" "+week;
document.getElementById("clock").innerHTML="当前系统时间:"+time;
}
window.setInterval("sysTime()",1000);
</script>
</head>
<body onload="sysTime()">
<div id="clock"></div>
</body>
</html>