時計
原案:フルタイム四苦 氏 (2000/04/01 登録)
只今の時間
表示サンプル
ソース記述内容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<title>時計</title>
<script type="text/javascript">
<!--
function clock() {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date= now.getDate();
var hour = now.getHours();
var min = now.getMinutes();
var sec = now.getSeconds();
if (month < 10) month = "0" + month;
if (date < 10) date = "0" + date;
if (hour < 10) hour = "0" + hour;
if (min < 10) min = "0" + min;
if (sec < 10) sec = "0" + sec;
document.f_date.i_date.value = year+"/"+month+"/"+date;
document.f_time.i_time.value = hour+":"+min+":"+sec;
setTimeout('clock()', 1000); // 1000msec = 1sec
}
// -->
</script>
</head>
<body>
<table border="0" align="center">
<tr>
<td>
<form name="f_date" nethod="post">
■Date:
<input type="text" name="i_date" size="14" style="text-align:right">
</form>
<form name="f_time" method="post">
■Time:
<input type="text" name="i_time" size="14" style="text-align:right">
</form>
<script type="text/javascript">
<!--
clock();
// -->
</script>
</td>
</tr>
</table>
</body>
</head>