I need to calculate if someone is over 18 from their date of birth using JQuery.
var curr = new Date();
curr.setFullYear(curr.getFullYear() - 18);
var dob =
keep in mind that all above answers work only for date using separator '/'. if you are using other that this then you have to replace that separator first.
var startDate = $('#start_date').val().replace('-','/');
var endDate = $('#end_date').val().replace('-','/');
if(startDate > endDate){
// do stuff here...
}
happy coding :D