I'm using jQuery DateTimePicker. I want to disable some specific hours in some specific dates. For example, I want to disable 09:00AM on 29/03/2022 and 10:00AM on 30/03/2022.
I already found this code, but it doesn't work. The inline calendar is running correctly.
var specificDates = ['29/03/2022', '30/03/2022'];
var hoursToTakeAway = [
[09, 10],
[10]
];
onGenerate: function(ct, $i) {
var ind = specificDates.indexOf(ct.dateFormat('d/m/Y'));
$('.xdsoft_time_variant .xdsoft_time').show();
if (ind !== -1) {
$('.xdsoft_time_variant .xdsoft_time').each(function(index) {
if (hoursToTakeAway[ind].indexOf(parseInt($(this).text())) !== -1) {
$(this).hide();
}
});
}
}
FINAL CODE IS WORKING : ( i'm using momentjs to use moment function on ct)
onGenerate: function(ct,$i) {
var ind = specificDates.indexOf(moment(ct).format('DD/MM/YYYY'));
$('.xdsoft_time_variant .xdsoft_time').show();
if(ind !== -1) {
$('.xdsoft_time_variant .xdsoft_time').each(function(index){
if(hoursToTakeAway[ind].indexOf(parseInt($(this).text())) !== -1) {
$(this).addClass('xdsoft_disabled');
}
});
}
}