(invalid date and time) problem

Hello. I have a question. I want it to be active on Sundays from 11:00 to 20:00 and Mondays from 13:00 to 17:00.
Be inactive only on date and time 2024-04-28T09:00.
But the problem is that it doesn’t work.

mobiscroll.datepicker(‘#demo-booking-datetime’, {
display: ‘inline’,
controls: [‘calendar’, ‘timegrid’],
stepMinute: 60,
max: new Date(now.getFullYear(), now.getMonth(), now.getDate()+ 10),
min: now
width: null,
returnFormat: ‘iso8601’,
calendarType: ‘week’,
calendarSize: 2,
valid: [
{start: ‘13:00’, end: ‘17:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘MO’ },
}
{start: ‘11:00’, end: ‘20:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘SU’ },
}
],
invalid: [{
start: ‘2024-04-28T09:00’,
end: ‘2024-04-28T09:00’
}],
});
i am new please guide me. thank you so much🙏

Hi @kokoviewpt :wave:

I’m not sure that I fully understand your requirement so, can you share a bit more information?

I’m asking because you mentioned that you want to set valid Mondays and Sundays with the mentioned time range and disable this specific date and time (2024-04-28T09:00). However, I’m curious about what happens with the other days? - I mean like Tuesdays, Wednesdays, Thursdays, etc.

thankyou so much. Because my problem was only that part, that’s why I didn’t send the rest.
I mean, for example, I want to validate Saturday, Sunday, Monday, … . for the period from 8:00 to 23:00. But I want only the date 2024-04-28T09:00 to be invalid among them. It means that all the days of the week are valid in the specified times and only the date 2024-04-28T09:00 is invalid. I gave an example here:
valid: [
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘SA’ },
}
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘SU’ },
}
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘MO’ },
}
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘TUE’ },
}
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: 'WED },
}
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘THU’ },
}
{start: ‘08:00’, end: ‘23:00’,
recurring: { repeat: ‘weekly’, weekDays: 'FRI },
}
],
invalid: [{
start: ‘2024-04-28T09:00’,
end: ‘2024-04-28T09:00’
}]

Here 04-28-2024 is Sunday. But because it is set to active on Sunday from 8:00 to 23:00 in the valid section, if I deactivate it in the invalid at 9:00, it does not work at all.
Is there a way to solve this problem?

Got it, thanks for clarifying :wink:

Yes, in this case, the right solution would be to use the recurringException in the valid option.

thankyou.
like this?
valid: [{
start: ‘11:00’,
end: ‘14:00’,
recurring: {
repeat: ‘weekly’,
weekDays: ‘SA,SU’
},
recurringException: [‘2024-05-04T12:00’]
}]

All date ranges of 2024-05-04 have been disabled. I want it to be disabled only at 12:00

Not entirely, because you can only pass dates (and not time) to recurringException. - sorry I didn’t mention that earlier.

The proper usage would be something like this :point_down:

    valid: [
            {
                start: '11:00',
                end: '13:30',
                recurring: {
                    repeat: 'weekly',
                    weekDays: 'SA, SU'
                },
                recurringException: ['2024-05-04']
            },
            {
                start: '2024-05-04T11:00:00',
                end: '2024-05-04T11:59:00',
            },
            {
                start: '2024-05-04T12:30:00',
                end: '2024-05-04T13:30:00',
            }
        ]

thank you. I use this time picker to reserve time. When the user selects the time and date, it is displayed in the form field using the following method:
onChange: function(event, inst) {
var time = event.value;
var fieldtime = document.getElementById(“time”);
fieldtime.value = time;
}
And then when the user clicks on the submit button in the form, the selected time is saved in the database so that time and date cannot be selected for other users.

But my problem is that because the time is stored in the database as 2024-05-04T12:00:00 (iso8601), so it should be placed in the invalid part of the code. So I can’t use the method you said because the reserved time is not recorded as a time interval.
Is there another method? Thank you very much for guiding me.

Thanks for the context!

In this case would be easier if you use/ switch to the invalid option. I mean using the invalid option for setting the invalid ranges per day and then it would be much easier to pass the invalid hour that was submitted by the user.

This is possible if all time periods are selectable.
But I want, for example, only Saturday (from 01:00 to 14:00) and Sunday (from 03:00 to 22:00) can be selected for booking.
Then, when the user reserved the date and time, for example, 2024-05-12T12:00 (Sunday 2024-05-12 at 12:00) and it was saved in the database, then Saturdays (from 1:00 to 14:00) and Sunday (from 3:00 to 22:00) can be selected for Be a reservation and deactivate only 2024-05-12T12:00 (Sunday 2024-05-12 at 12:00). The reserved times are also stored in the database in ISO format.
valid: [{
start: ‘01:00’,
end: ‘14:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘SA’ },
},{
start: ‘03:00’,
end: ‘22:00’,
recurring: { repeat: ‘weekly’, weekDays: ‘SU’ },
}
],
invalid: [{
start: ‘2024-05-12T12:00’,
end: ‘2024-05-12T12:00’
}]
Sorry for the many questions I ask. thank you