元の生のjsの書いた現在の年の日付の週と時間の表示
14562 ワード
話が多くないです.コードは以下の通りです.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> </title>
</head>
<body onload="startTime()">
<div id="time"></div>
</body>
<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
var myyear=today.getFullYear();
var mymonth=today.getMonth();
var monthArray=["1 ","2 ","3 ","4 ","5 ","6 ","7 ","8 ","9 ","10 ","11 ","12 "]
var mynowdate=today.getDate();
var myday=today.getDay();
var dayArray=[" "," "," "," "," "," "," "]
m=checkTime(m)
s=checkTime(s)
document.getElementById('time').innerHTML=myyear+" "+monthArray[mymonth]+mynowdate+" "+dayArray[myday]+h+":"+m+":"+s
setTimeout('startTime()',1000)
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</html>