what am I doing wrong
what am I doing wrong
Hi @ctedesco3307,
the problem you face is that the .val() returns a string which you need to change into a date.
The following code works as expected.
dob = Date.parse('5/30/2000');
var today = new Date();
var age = Math.floor((today-dob) / (365.25 * 24 * 60 * 60 * 1000));
console.log(age);
// Expected output: 23
One thing you have to take care is the timezone. In case it's a global application you will have the date as you currently do in dd/mm/yyyy but probably some others in mm/dd/yyyy
--------------------------------------------------------------------------------------
Hope that helps.
If the post solves your problem, please mark it as solution. If it helps, consider a thumbs up.