Skip to content

Instantly share code, notes, and snippets.

@Rameshwar-ghodke
Created April 13, 2017 11:41
Show Gist options
  • Save Rameshwar-ghodke/2072b43173de837ce3454dacd19f9311 to your computer and use it in GitHub Desktop.
Save Rameshwar-ghodke/2072b43173de837ce3454dacd19f9311 to your computer and use it in GitHub Desktop.
var dob = wholedata[4];
if(dob.length==0)
{
AgeYear=0;
$("#user_age").val(AgeYear);
}
else
{
BirthDate=dob.split("-");
BirthDay=BirthDate[2];
BirthMonth=BirthDate[1];
BirthYear=BirthDate[0];
TodayDate=new Date();
CurrentDay=TodayDate.getDate();
CurrentMonth="0"+parseInt(TodayDate.getMonth()+1);
CurrentYear=TodayDate.getFullYear();
AgeDay=CurrentDay-BirthDay;
AgeMonth=CurrentMonth-BirthMonth;
AgeYear=CurrentYear-BirthYear;
if(AgeMonth < 0 || (AgeMonth==0 && AgeDay < 0))
{
AgeYear=parseInt(AgeYear)-1;
}
else
{
AgeYear=parseInt(AgeYear);
}
$("#user_age").val(AgeYear);
}
@Rameshwar-ghodke
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment