Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default date in daterangepicker?

Is there any way to simply set default date as current + 5 day ahead in daterangepicker? Like this:

$('.selector').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
setDate: '+5d',
minDate: new Date()
}, function(start, end, label) {
    $('.selector').val(start.format("YYYY-MM-DD"));

});
like image 888
Sagar Nepali Avatar asked Jun 27 '17 09:06

Sagar Nepali


People also ask

How do you change the date on a date range picker?

How to get the start and end date of the selected range in the Flutter Date Range Picker (SfDateRangePicker) In the Flutter Date Range Picker, you can get the start and end date of the selected range by using the startDate and endDate property of the onSelectionChanged callback args.

How do you set a date range in HTML?

The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from. If min and max values are not set then default min value is set to “01-01-1920” and default max value is set to “01-01-2120”.


1 Answers

Like so. You also don't need that callback function since the format string is configurable.

$('.selector').daterangepicker({
    singleDatePicker: true,
    showDropdowns: true,
    startDate: moment().add(5, 'day'),
    minDate: moment(),
    locale: { 
        format: 'YYYY-MM-DD'
    }
});
like image 83
Dan Grossman Avatar answered Oct 17 '22 20:10

Dan Grossman