首页 > 代码库 > 网页显示日期
网页显示日期
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function getTime(){
var myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth();
var day = myDate.getDay();
var hour = myDate.getHours();
var minutes = myDate.getMinutes();
var seconds = myDate.getSeconds();
document.getElementById("time").innerHTML=year+"年"+month+"月"+day+"日 "+hour+"时"+minutes+"分"+seconds+"秒";
}
setInterval("getTime()",1000);
//document.getElementById("time").innerHTML = 22;
</script>
</head>
<body>
现在时间是:<p id="time"></p>
</body>
</html>