32. 날짜관련 내장객체
.NET프로그래밍/JavaScript 1.2 2009. 8. 13. 17:32 |<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>날짜관련내장객체</title>
<script src="date.js" type="text/javascript"></script>
<script src="time.js" type="text/javascript"></script>
<script type="text/javascript">
// 현재 시간을 출력
var today = new Date();
// 출력
document.write(today.getFullYear() + "<br />");
document.write((today.getMonth() + 1) + "<br />");
document.write(today.getDate() + "<br />");
document.write(today.getDay() + "<br />"); // 0요일(일) ~ 6요일(토)
document.write(today.getHours() + "<br />");
document.write(today.getMinutes() + "<br />");
document.write(today.getSeconds() + "<br />");
document.write(today.getMilliseconds() + "<br />");
// 자바스크립트 확장
// date.js 검색/다운로드 및 사용 ==> '날짜'관련(DateTime) 명령어
var il = Date.getDaysInMonth(2008, 2 - 1); //
document.write(il + "<br />");
// 시간차 : TimeSpan ==> time.js 검색/ 다운로드 및 사용 ==> '시간차' 관련 명령어
var now = Date.today();
var birth = Date.parse("1982-02-05");
var span = new TimeSpan(now - birth);
document.write(span.getDays() + "일 살았습니다.");
</script>
</head>
<body>
</body>
</html>
'.NET프로그래밍 > JavaScript 1.2' 카테고리의 다른 글
텍스트박스 포커스 이동(주민번호입력 예제) (0) | 2010.04.14 |
---|---|
33. 문자열관련함수 (0) | 2009.08.13 |
31. 이벤트(Event) (0) | 2009.08.13 |
30. 자바스크립트에서 스타일시트 접근 (0) | 2009.08.11 |
29. 드롭다운리스트체크(selectedIndex 사용) (0) | 2009.08.11 |