現在日時をテキストで表示
 
ソース
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Clock(){
youbi=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
myDate=new Date();
myyear=myDate.getFullYear();
mymonth=myDate.getMonth()+1;
myday=myDate.getDate();
myyoubi=youbi[myDate.getDay()];
myhour=myDate.getHours();
myminute=myDate.getMinutes();
mysecond=myDate.getSeconds();
if (mymonth<10) {mymonth="0"+mymonth}
if (myday<10) {myday="0"+myday}
if (myhour<10) {myhour="0"+myhour}
if (myminute<10) {myminute="0"+myminute}
if (mysecond<10) {mysecond="0"+mysecond}
today="<font style='font-size:13px;color:#808080'>"+myyear+"/"+mymonth+"/"+myday+" ("+myyoubi+") "+myhour+":"+myminute+":"+mysecond+"</font>";
document.all("M1").innerHTML = today;
setTimeout("Clock()",1000);
}
//-->
</SCRIPT>
</head>
<body onload="Clock()">
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write("<span id='M1'></span>");
//-->
</SCRIPT>
</body>
</html> 
JavaScript GarageのTopへ戻る