사이트 내 전체검색
오늘 날짜와 시간 구하기
로빈아빠
https://cmd.kr/javascript/611 URL이 복사되었습니다.

본문

오늘 날짜와 시간 구하기

---------- 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> 

댓글목록

등록된 댓글이 없습니다.

831 (3/17P)

Search

Copyright © Cmd 명령어 3.149.254.110