If I use this, the change function will only fire once at opening. Selecting a different date will not trigger the change function anymore. There are 2 datetimepickers in the form. The first is to set a date and the second has to autofill the same date as the first and the time minus 3 hours.
$("#ed").on("dp.change", function (e) {
var d = new Date(e.date);
var month = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear();
var hour = d.getHours() - 3;
var min = d.getMinutes();
var setter = day + '-' + month + '-' + year + ' ' + hour + ':' + min;
$('#re').data("DateTimePicker").defaultDate(setter);
});
Try this should work....
$("#ed").on("dp.change", function (e) {
//Get new date value from the field on change
var d = new Date(e.date);
//This is for fixing the our to -3 Hours
//which will return to millisecond value
d.setHours(d.getHours()-3);
//Use .date()... please refer Bootstrap datetimepicker doc
$('#re').data("DateTimePicker").date(d);
});