Daterangepicker

Date Range Picker with two different inputs

Daterangepicker is a JavaScript component for choosing date ranges, dates and times.
While the documentation is very straight forward regarding the use of a single element, the date range picker can also be used on two elements which will produce a two part date range rather than one.
This can also be found here in more detail.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$('#search_checkin, #search_checkout').daterangepicker({
    locale: {
        format: 'DD-MM-YYYY'
    },
    "alwaysShowCalendars": true,
    "minDate": currentDate,
    "maxDate": moment().add('months', 1),
    autoApply: true,
    autoUpdateInput: false
    }, function(start, end, label) {
        var selectedStartDate = start.format('DD-MM-YYYY'); // selected start
        var selectedEndDate = end.format('DD-MM-YYYY'); // selected end

        $checkinInput = $('#search_checkin');
        $checkoutInput = $('#search_checkout');

        $checkinInput.val(selectedStartDate);
        $checkoutInput.val(selectedEndDate);

        checkOutPicker.setStartDate(selectedStartDate);
        checkOutPicker.setEndDate(selectedEndDate);

        checkInPicker.setStartDate(selectedStartDate);
        checkInPicker.setEndDate(selectedEndDate);
});