<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>javascript </title>
</head>
<body>
<h3>javascript Date --- </h3>
<div id="did" style="height:30px;width:300px;background:#f60;font-size:19px;text-align:center;line-height:30px"></div>
<script type="text/javascript">
// ,
function showDate(){
//
var dd = new Date();
//
var year = dd.getFullYear();//
var month = dd.getMonth()+1; // 1 getMonth() 1-11
var day = dd.getDay();//
var hour =dd.getHours();//
var minute = dd.getMinutes();//
var second = dd.getSeconds();//
// 0-9 ,
second = (second<10)?"0"+second:second;
//
var str =year +"-"+ month +"-"+ day +" "+ hour +":"+ minute +":"+second;
document.getElementById("did").innerHTML=" :"+str;
//
//alert(str);
//document.write(str);
}
setInterval("showDate()",1000);
</script>
</body>
</html>
この記事は「夢の翼」ブログから来ました.転載は作者に連絡してください.