Интервью

Сортировать статьи по: дате | популярности | посещаемости | алфавиту
Назад
1 2 3 4 5
var input = document.getElementById('date'); var result = document.getElementById('result'); input.onchange = getAge; getAge(); function getAge() { var strDate = document.getElementById('date').value; var arrDate = strDate.split(/\D+/g); var date = new Date(arrDate[2], arrDate[1] - 1, arrDate[0]); var now = new Date(); var age = now.getFullYear() - date.getFullYear(); now.setFullYear(date.getFullYear()); if (now < date) age--; result.innerHTML = age+' лет'; }