I am using jquery datetimepicker.
i am able to disable time before current time by using following code.
$("#startDate").datetimepicker({
dayOfWeekStart: 1,
minDate: 0,
format: 'd/m/Y H:i',
formatTime: 'H:i',
formatDate: 'd/m/Y',
startDate: currentDateTime,
ampm: true,
});
I am having two controls.
Start date and
End date.
condition:
when user select any date time, value of
EndDate will be a day and half an hour ahead.
e.g. if startdate is 11-05-2016 18:00 then
endDate will be 12-05-2016 18:30 (user will not be able to select previous time wrt to endDate time i.e. disable time upto 18:00)
I have achieved above functionality but fails to disable time.
I have used moment js to format date.
What I have tried:
var jsDate = moment($("#JobDate").val(), 'DD-MM-YYYY HH:mm');
var minimum = function(jsDate){
if(jsDate.getMinutes()==0){
this.setOptions({
minTime : jsDate.getHours()+":"+(parseInt(jsDate.getMinutes())+33),
});
}
else{
this.setOptions({
minTime : (parseInt(jsDate.getHours())+1)+":00",
});
}
};
$("#EndDate").datetimepicker({
startDate:datetime1,
onChangeDateTime:minimum,
onShow:minimum,
});
var dt = new Date(jsDate.add(1,'days'));
$("#startDate").val(dt.toString("DD-MM-YYYY HH:mm");
from jquery datetime tutorial i tried above code but it's not working.
if I'm uses
minTime : 0 then it is disabling previous time wrt to current time. and that is perfactly fine in the case of startDate. When i try to disable previous time wrt to specific time(i.e.disable time from startDate's selected time for EndDate) as shown above, its not working.
What's wrong with the code?