I am using the following jQuery plugin: https://github.com/xdan/datetimepicker to implement a start and end date, where the end cannot be before the start and the start cannot be after the end. My code is bellow, based off the example in the documentation (I need the time as well as date): http://xdsoft.net/jqplugins/datetimepicker/#range
The problem is that limits aren't being set. From the code I can see that https://github.com/xdan/datetimepicker/blob/master/jquery.datetimepicker.js#L509 requires the minDate
and maxDate
to have a -+
in front of them. Is this a bug or am I missing something?
var format = "Y-m-d H:i:s";
var startSelector = "input[type='datetime-picker'][name='start']";
var endSelector = "input[type='datetime-picker'][name='end']";
$(startSelector).datetimepicker( {
format : format,
onShow : function(ct) {
var val = $(endSelector).val();
console.log('start max val: '+val);
var opts = {
formatDate : "Y-m-d",
maxDate : val ? '+'+val.split(' ')[0] : false
};
this.setOptions(opts);
},
});
$(endSelector).datetimepicker( {
format : format,
onShow : function(ct) {
var val = $(startSelector).val();
console.log('end min val: '+val);
var opts = {
formatDate : "Y-m-d",
minDate : val ? '-'+
val.split(' ')[0] : false
};
this.setOptions(opts);
},
});