Search
 
SCRIPT & CODE EXAMPLE
 

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'));
Comment

Javascript get years since date

getAge() {
    let currentTime = new Date().getTime();
    let birthDateTime= new Date('DATE GOES HERE').getTime();
    let difference = (currentTime - birthDateTime);
    return Math.floor(difference/(1000*60*60*24*365));
}
Comment

js get years since date

getAge() {
    let currentTime = new Date().getTime();
    let birthDateTime= new Date('DATE GOES HERE').getTime();
    let difference = (currentTime - birthDateTime);
    Math.floor(difference/(1000*60*60*24*365));
}
Comment

Javascript get years since date

getAge() {
    let currentTime = new Date().getTime();
    let birthDateTime= new Date('DATE GOES HERE').getTime();
    let difference = (currentTime - birthDateTime);
    return Math.floor(difference/(1000*60*60*24*365));
}
Comment

Javascript get years since date

getAge() {
    let currentTime = new Date().getTime();
    let birthDateTime= new Date('DATE GOES HERE').getTime();
    let difference = (currentTime - birthDateTime);
    return Math.floor(difference/(1000*60*60*24*365));
}
Comment

Javascript get years since date

getAge() {
    let currentTime = new Date().getTime();
    let birthDateTime= new Date('DATE GOES HERE').getTime();
    let difference = (currentTime - birthDateTime);
    return Math.floor(difference/(1000*60*60*24*365));
}
Comment

js get years since date

getAge() {
    let currentTime = new Date().getTime();
    let birthDateTime= new Date('DATE GOES HERE').getTime();
    let difference = (currentTime - birthDateTime);
    Math.floor(difference/(1000*60*60*24*365));
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: after load page jquery 
Javascript :: js pi 
Javascript :: react check if string is mail 
Javascript :: regex valid day 
Javascript :: Manifest 3 content security policy 
Javascript :: javascript detect enter press on input 
Javascript :: delegate click in jquery 
Javascript :: scoll a div to bottom in angular 
Javascript :: get the placeholder value jquery 
Javascript :: javascript fetch api post 
Javascript :: select2 get selected value 
Javascript :: how to detect safari browser in javascript 
Javascript :: convert 2 dimensional array to js object 
Javascript :: align left text in reactstrap 
Javascript :: fetch await 
Javascript :: clz32() js 
Javascript :: confirm message in jquery 
Javascript :: import json javascript 
Javascript :: open link in new window chrome mac shortcut 
Javascript :: check jquery version in chrome 
Javascript :: node js favicon.ico 
Javascript :: regex match everything before string 
Javascript :: jest reset spy 
Javascript :: random code js 
Javascript :: take input from input array field jquery 
Javascript :: convert stream to string javascript 
Javascript :: javascript get domain name from string 
Javascript :: regex expression dd/mm/yyyy javascript 
Javascript :: convert 24 hours to 12 hours javascript 
Javascript :: how to use current data in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =