日付を表示する




<SCRIPT LANGUAGE="JavaScript">
	weeks=new Array("日","月","火","水","木","金","土");
	today=new Date();
	y=today.getFullYear();
	m=today.getMonth()+1;
	d=today.getDate();
	w=weeks[today.getDay()];
	document.write("今日は<FONT COLOR='#009900' SIZE='5'>",y,"</FONT>年");
	document.write("<FONT COLOR='#009900' SIZE='5'>",m,"</FONT>月");
	document.write("<FONT COLOR='#009900' SIZE='5'>",d,"</FONT>日");
	document.write("<FONT COLOR='#009900' SIZE='5'>",w,"</FONT>曜日");
</SCRIPT>


時刻を表示する

ただいまです。

<SCRIPT LANGUAGE="JavaScript">
function watch() {
	now = new Date();
	hour = now.getHours();
	min = now.getMinutes();
	sec = now.getSeconds();
	if (hour < 10) {
		hour = "0" + hour;
	}
	if (min < 10) {
		min = "0" + min;
	}
	if (sec < 10) {
		sec = "0" + sec;
	}
	document.forms[0].elements[0].value = hour+":"+min+":"+sec;
	setTimeout('watch()', 999); // 1000msec = 1sec
}
watch();
</SCRIPT>