문서의 이전 판입니다!


자바스크립트 (Javascript)로 만나이를 계산해보자

자바스크립트 (Javascript)로 만나이를 계산해보자. (출처)

<script>
var birthday = new Date("63/01/01");
var today = new Date();
var years = today.getFullYear() - birthday.getFullYear();
 
// Reset birthday to the current year.
birthday.setFullYear(today.getFullYear());
 
// If the user's birthday has not occurred yet this year, subtract 1.
if (today < birthday)
{
    years--;
}
document.write("당신은 만" + years + "세 입니다.");
 
// Output: You are <number of years> years old.
 
</script>

같이 보기


CC Attribution-Noncommercial-Share Alike 4.0 International 별도로 명시하지 않을 경우, 이 페이지의 내용은 다음 라이선스에 따라 사용할 수 있습니다: CC Attribution-Noncommercial-Share Alike 4.0 International
tech/javascript_만나이_계산.1466653209.txt.gz · 마지막으로 수정됨 (바깥 편집)