I'm passing my calendar selected date of birth
to following JS function for calculating Age:
var DOBmdy = date.split("-");
Bdate = new Date(DOBmdy[2],DOBmdy[0]-1,DOBmdy[1]);
BDateArr = (''+Bdate).split(' ');
//document.getElementById('DOW').value = BDateArr[0];
Cdate = new Date;
CDateArr = (''+Cdate).split(" ");
Age = CDateArr[3] - BDateArr[3];
Now, lets say, input age is: 2nd Aug 1983
and age count comes: 28
, while as August month has not been passed yet, i want to show the current age of 27
and not 28
Any idea, how can i write that logic, to count age 27
perfectly with my JS function.
Thanks !