<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
var t_flg=true;
function dsp_Hours(_hour) {
if (t_flg || (_hour > 0 && _hour < 13)) {
if (_hour == "0") _hour = 12;
return (_hour);
}
if (_hour == 0) {
return (12);
}
return (_hour-12);
}
function add_Zero(_inv) {
if (_inv > 9) {
return "" + _inv;
}
return "0" + _inv;
}
function dsp_AmPm() {
if (t_flg) {
return ("");
}
if (now.getHours() < 12) {
return (" AM");
}
return (" PM");
}
function dsp_TheTime() {
now = new Date;
_hh = dsp_Hours(now.getHours());
_mm = add_Zero(now.getMinutes());
_ss = add_Zero(now.getSeconds()) + dsp_AmPm();
document.frm.TimeArea.value = _hh +":"+ _mm +":"+ _ss;
setTimeout("dsp_TheTime()",1000);
}
//-->
</SCRIPT>
<BODY onLoad="dsp_TheTime()">
<center>
<form name=frm>
<input type=text name=TimeArea size=12><p>
<input type=button value=24時間表示 onClick={t_flg=true}>
<input type=button value=12時間表示 onClick={t_flg=false}>
</form></center>
</BODY>
</HTML>
|