<p id="demo"></p>
<script>
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return number+" "+titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
document.write( declOfNum(new Date().getFullYear() - 2005, ['год', 'года', 'лет']) );
</script>
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return number+" "+titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
var date = declOfNum(new Date().getFullYear() - 2005, ['год', 'года', 'лет'])
var el = document.getElementById("demo")
el.innerText = date