Only got so far before must stop (time). Here's where I got to, perhaps it will help.
You must turn your field values back into dates, as so:
var t1 = $("#dop").val();
var t1d = new Date(t1);
Finished example. If this doesn't do what you want, please respond with details:
$(function() {
$("#dop").datepicker({
dateFormat: "dd/mm/yy",
onSelect: function(dateText, instance) {
date = $.datepicker.parseDate(instance.settings.dateFormat, dateText, instance.settings);
date.setMonth(date.getMonth() + 12);
$("#wed").datepicker("setDate", date);
if ($('#dop') && $('#wed')) {
var t1 = $("#dop").val();
//alert(t1);
var t1d = new Date(t1);
//alert(t1d);
var t2 = $("#wed").val();
var t2d = new Date(t2);
var diff = (t2d - t1d)/86400000;
//alert(diff);
$('#days').val(diff);
}
}
});
$("#wed").datepicker({
dateFormat: "dd/mm/yy",
});
});
Here's another jsFiddle example where the number of months to add is stored in a hidden input field.