smalot / bootstrap-datetimepicker

Both Date and Time picker widget based on twitter bootstrap (supports Bootstrap v2 and v3)
http://www.malot.fr/bootstrap-datetimepicker/
Apache License 2.0
3.49k stars 1.65k forks source link

Feature Request: is it possible to set hourMin / hourMax depending on the choosen Date? #667

Open Milenoi opened 7 years ago

Milenoi commented 7 years ago

Hi dear Community,

i have a Question.

I need to customize my datetimepicker: Mo-Fr: hourMin=9, hourMax=21 Sat-So: hourMin=12, hourMax=18

additionally depending on special Dates (holidays!) i need to change this in the following way: holiday (e.g. 12.06.2017): hourMin=13, hourMax=17

tbc...

is there a way / idea to realize this with this plugin?

Thank you for your opinion / help ;)

Mel

Lexys-zz commented 7 years ago

I have the same issue, have you found the solution? :)

RinkAttendant6 commented 7 years ago

Have you tried using the onRenderHour option for the datepicker?

The function would be something like this:

onRenderHour(date) {
    var day = date.getUTCDay();
    var hour = date.getUTCHours();
    if ((day === 0 || day === 6) && (hour < 9 || hour > 21))
        return ['disabled'];
    }
    if (hour < 12 || hour > 18) {
        return ['disabled'];
    }
}

I wrote the code out this way for clarity but it can certainly be simplified into one if.

echan00 commented 6 years ago

Same here, interested in this feature!

echan00 commented 6 years ago

@RinkAttendant6 Doesn't the 'onRenderHour' function use variable 'hour' instead of 'date'? I am having trouble accessing the date variable during render of hours

RinkAttendant6 commented 6 years ago

Regarding https://github.com/smalot/bootstrap-datetimepicker/issues/667#issuecomment-345619592 @echan00 You can call the variable hour if you want but it is still an instance of a Date object

kabircse commented 6 years ago

Hi, I want to disable some hours of dates like, 12.06.2018 5.30 am, 12.06.2018 2.00 pm. Is it possible ?