javascript get years since a date

Solutions on MaxInterview for javascript get years since a date by the best coders in the world

showing results for - "javascript get years since a date"
Heidi
01 Nov 2016
1function getAge(dateString) {
2   var ageInMilliseconds = new Date() - new Date(dateString);
3   return Math.floor(ageInMilliseconds/1000/60/60/24/365); // convert to years
4}
5console.log(getAge('1997-04-23'));