Answers for "javascript get years since a date"

1

javascript get years since a date

function getAge(dateString) {
   var ageInMilliseconds = new Date() - new Date(dateString);
   return Math.floor(ageInMilliseconds/1000/60/60/24/365); // convert to years
}
console.log(getAge('1997-04-23'));
Posted by: Guest on May-31-2021

Code answers related to "javascript get years since a date"

Code answers related to "Javascript"

Browse Popular Code Answers by Language