Javascript Date getAge()
Date.prototype.getAge = function() { var today = new Date(); var birthDate = this; var age = today.getFullYear() - birthDate.getFullYear(); var m = today.getMonth() - birthDate.getMonth(); if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { age--;//from ww w . j av a 2 s. c o m } return age; }