Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #years #date
ADD COMMENT
Topic
Name
1+5 =