[java] 스크립트 – 날짜와 시간 표시 하기 -2
* clock
이 스크립트는 현재의 날짜와 시간을 실시간으로 박스안에 보여주고 있습니다
<SCRIPT LANGUAGE=”JavaScript”>
function gettheDate() {
Todays = new Date(); TheDate = “” + (Todays.getMonth()+1) +” . “+ Todays.getDate() + ” . ” + Todays.getYear()
}
var timerID = null;
var timerRunning = false;
function stopclock () {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = “” + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? “:0” : “:”) + minutes
timeValue += ((seconds < 10) ? “:0” : “:”) + seconds
timeValue += (hours >=12) ? ” P.M.” : ” A.M.”
document.clock.face.value = timeValue;
document.clock.date.value = TheDate;
timeID = setTimeout(“showtime()”,1000);
timerRunning = true;
}
function startclock () {
stopclock();
gettheDate()
showtime();
}
// –>
</SCRIPT>
<BODY onLoad=”startclock ()”>
<FORM NAME=”clock” onSubmit=”0″>
<INPUT TYPE=”text” NAME=”face” SIZE=11 VALUE =””>
<INPUT TYPE=”text” NAME=”date” SIZE=11 VALUE =””>
</FORM>
1 Response
… [Trackback]
[…] Information on that Topic: nblog.syszone.co.kr/archives/815 […]