Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Created February 11, 2022 06:07
Show Gist options
  • Save aimahdi/a66e75fef05988b3a3c15ae7886b2b2d to your computer and use it in GitHub Desktop.
Save aimahdi/a66e75fef05988b3a3c15ae7886b2b2d to your computer and use it in GitHub Desktop.
{
onChange: function(selectedDate, dateString) {
var birthDate = selectedDate[0] ;
birthDate.setDate(birthDate.getDate() +1);
var today = new Date();
var age = today.getTime() - birthDate.getTime();
var inYears = age/(1000*60*60*24*365);
document.querySelector("[name='hidden']").value = parseInt(inYears);
jQuery("[name='hidden']").trigger('change');
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment