웹마스터 팁
page_full_width">
오늘 날짜와 시간
2003.05.20 18:16
날짜와 시간을 보여줍니다. 보니 날짜구하는 소스는 있는데 시간은 없더군요.
아무쪼록 도움이 되길 바랍니다.
---------- head 부분 시작 -------------
<script Language="JavaScript">
var timeStr, dateStr;
function clock() {
now= new Date();
hours= now.getHours();
minutes= now.getMinutes();
seconds= now.getSeconds();
timeStr= "" + hours;
timeStr+= ((minutes < 10) ? ":0" : ":") + minutes;
timeStr+= ((seconds < 10) ? ":0" : ":") + seconds;
document.clock.time.value = timeStr;
date= now.getDate();
month= now.getMonth()+1;
year= now.getYear();
dateStr= "" + month;
dateStr+= ((date < 10) ? "/0" : "/") + date;
dateStr+= "/" + year;
document.clock.date.value = dateStr;
Timer= setTimeout("clock()",1000);
}
</script>
------------ head 부분 끝 -----------------
------------ body 태그에 넣어주세요. -------------
<body onLoad="clock()">
------------ 페이지 적당한곳에 들어갈 부분 --------
<form name="clock">
시간:
<input type="text" name="time" size="8" value=""><br>
날짜:
<input type="text" name="date" size="8" value="">
</form>
아무쪼록 도움이 되길 바랍니다.
---------- head 부분 시작 -------------
<script Language="JavaScript">
var timeStr, dateStr;
function clock() {
now= new Date();
hours= now.getHours();
minutes= now.getMinutes();
seconds= now.getSeconds();
timeStr= "" + hours;
timeStr+= ((minutes < 10) ? ":0" : ":") + minutes;
timeStr+= ((seconds < 10) ? ":0" : ":") + seconds;
document.clock.time.value = timeStr;
date= now.getDate();
month= now.getMonth()+1;
year= now.getYear();
dateStr= "" + month;
dateStr+= ((date < 10) ? "/0" : "/") + date;
dateStr+= "/" + year;
document.clock.date.value = dateStr;
Timer= setTimeout("clock()",1000);
}
</script>
------------ head 부분 끝 -----------------
------------ body 태그에 넣어주세요. -------------
<body onLoad="clock()">
------------ 페이지 적당한곳에 들어갈 부분 --------
<form name="clock">
시간:
<input type="text" name="time" size="8" value=""><br>
날짜:
<input type="text" name="date" size="8" value="">
</form>
댓글 3
-
REDsun
2003.05.20 20:36
제가 원하던 소스 인데 .. 좋은 소스 감사드립니다. -
sue~*
2003.08.19 23:07
잘 썼습니다. 감사~~ ^^* -
이명우
2006.10.11 02:11
다좋은데.. 박스 없이 그냥 쓰는건 안되나요? 네모 박스에 있어서 너무 튀는데...초도 안나왔으면 좋을듯...