From Evernote: |
생일 입력해서 연령 구하는 프로그램 |
<!DOCTYPE html>
<html lang="ko" >
<head>
<meta charset="utf-8" >
<title> Making birthday calculator</ title>
<script src="birthday.js" ></script>
</head>
<body>
<h1> 날짜 계산 연습</h1 >
<p> Birthday : <input type="text" name="birthday" id="birthday"
value="1988-02-14" ></p>
<p>< input type ="button" value="Calculate" onclick="getAge();"></ p>
<p> 태어나서부터 <span id="daysPast"> ???</span >일 경과해서 아마
<span id="age" >???</ span>살정도 입니다. </p>
</body>
</html>
|
function getAge() {
// 입력값 얻어오기
var birthday = document.getElementById('birthday' ).value.split("-");
// 날짜 오브젝트 작성
var d1 = new Date(birthday[0],birthday[1]-1,birthday[2]);
//월은 0부터 시작하므로
// 1970년 1월 1일부터 birthday로 지정한 시간까지의 경과 시간을 ms단위로 계산
var d2 = new Date();
// 1970년 1월 1일부터 지금까지의 시간을 ms 단위로 계산
// 일수, 연령 계산
var diff = d2.getTime() - d1.getTime();
var daysPast = Math.floor(diff / (1000 * 60 * 60 * 24));
var age = Math.floor(daysPast / 365.25);
//결과 표시
document.getElementById( "daysPast").innerHTML = daysPast;
document.getElementById( "age").innerHTML = age;
}
|
WinStar World Casino and Resort announces grand opening
ReplyDeleteWinStar World Casino and Resort, which opened in 인천광역 출장안마 1994 as the new gambling venue of the 세종특별자치 출장안마 from the state of 목포 출장마사지 Michigan's Wolverine 남양주 출장안마 and the 부산광역 출장마사지 state's largest casino