8

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"));

});
Samurai Jack
  • 2,985
  • 8
  • 35
  • 58
Sagar Nepali
  • 179
  • 1
  • 4
  • 16

3 Answers3

11

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'
    }
});
Dan Grossman
  • 51,866
  • 10
  • 112
  • 101
0
var someDate = new Date();
var numberOfDaysToAdd = 5;
someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
$('.selector').val(formatDate(someDate));

this helped

Sathiamoorthy
  • 8,831
  • 9
  • 65
  • 77
Sagar Nepali
  • 179
  • 1
  • 4
  • 16
-1

Try this:

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

});

var Today= new Date();
Today.setDate(Today.getDate() + 5);//any date you want
$('.selector').daterangepicker('setDate', Today);
GaAd
  • 145
  • 6