Action disabled: source

자바스크립트 (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>

같이 보기