<!--1. 아래의 스크립트를 원하는 위치에 넣으세요.^^ -->
<SCRIPT language="JavaScript">
<!--
var today = new Date();
document.write(today.getYear()+ "년 ");
document.write((today.getMonth()+ 1) + "월");
document.write(today.getDate()+ "일 ");
document.write(today.getHours()+"시 ");
document.write(today.getMinutes()+ "분 ");
document.write(today.getSeconds()+ "초 ");
//-->
</SCRIPT>
결과는
2006년 5월2일 17시 9분 35초
빨갱이반장을 참조글 :
getYear(), getMonth(), getDate(), getHours(), getMiinutes() getSeconds() 함수기 때문에 외우시구요
단 년,달,월,일,시,분,초 맨앞에 영문자는 항상 대문자로 해야합니다.
또 getMonth() +1 이 있는 왜 해주어야 하는냐면 +1일 하지 않으면 0월달로 인식이 되기 때문입니다. 그래서 +1일 해주어야 합니다.
PhP로 그렇게 된다고 하시네요 샌님께서 참조하세요..
두번째 응용한 시간날짜자바스크립트
<!--1. 아래의 스크립트를 원하는 위치에 넣으세요.^^ -->
<SCRIPT LANGAGE="JavaScript">
<!--
var today = new Date();
document.write("<font size=5 color=red> <b> 오늘날짜는" + today.getYear()+ "년 ");
document.write((today.getMonth()+ 1) + "월");
document.write(today.getDate()+ "일, <br> 현재 시각은 ");
document.write(today.getHours()+ "시");
document.write(today.getMinutes()+ "분 ");
document.write(today.getSeconds()+ "초입니다. </b> </font>");
// -->
</SCRIPT>
결과는
오늘날짜는2006년 5월2일,
현재 시각은 17시23분 38초입니다.
'프로그래밍 > html & jsp' 카테고리의 다른 글
자바스크립트 자리수 맞추기 (0) | 2009.06.10 |
---|---|
체크박스 전체 선택/해제 (0) | 2009.06.10 |
자바스크립트 특정 영역 프린트 (0) | 2009.06.10 |
javascript [필수] (0) | 2009.06.10 |
테이블의 타이틀은 고정시키고 상하좌우 스크롤하기 (0) | 2009.06.10 |