atatanasov / gijgo

Gijgo - Free Javascript Controls
http://gijgo.com
MIT License
475 stars 188 forks source link

datetimepicker range? #475

Open mealinux opened 5 years ago

mealinux commented 5 years ago

there is datepicker range but no datetimepicker range so with timepicker?

manuelgeek commented 4 years ago

this is what i use in the scenario, looks longer but more of a hack

var today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate());
$('#startDate').datetimepicker({
            footer: true,
            modal: true,
            format: 'dd-mm-yyyy HH:MM:ss',
            uiLibrary: 'bootstrap',
            iconsLibrary: 'fontawesome',
            datepicker : {
                minDate: today,
                disableDates:  function (date) {
                    if($('#endDate').val() !== ''){
                        var parts = $('#endDate').val().split('-');
                        const currentDate = new Date(parts[2].split(' ')[0], parts[1] - 1, parts[0]);
                        return date <= currentDate ? true : false;
                    }
                    return true;
                }
            }

        });
        $('#endDate').datetimepicker({
            footer: true,
            modal: true,
            format: 'dd-mm-yyyy HH:MM:ss',
            uiLibrary: 'bootstrap',
            iconsLibrary: 'fontawesome',
            datepicker: {
                disableDates:  function (date) {
                    if($('#startDate').val() !== '') {
                        var parts = $('#startDate').val().split('-');
                        const currentDate = new Date(parts[2].split(' ')[0], parts[1] - 1, parts[0]);
                        return date >= currentDate ? true : false;
                    }
                    return true;
                }
            }
        });
manojexamai commented 3 months ago

Nope. This does not work correctly with BooStrap5. And looks like this project does not have any active support.