foundation-datepicker icon indicating copy to clipboard operation
foundation-datepicker copied to clipboard

custom startDate and endDate

Open tonumikk opened this issue 8 years ago • 1 comments

Thanks for the nice date picker! Is there a way to limit display of dates to start 7 days from today and end 3 months from now? I noticed that startDate and endDate options accept the value of "today". How could I write startDate:'today' + 7 days? endDate: 'today' + 3 months?

Thanks!

tonumikk avatar Jan 27 '17 18:01 tonumikk

Hi tonumikk,

you can easily achieve this by precalculating the desired date into a variable:

// preparing date variables
var startDate = new Date();
var endDate = new Date();
startDate.setDate(startDate.getDate() + 7);
endDate.setMonth(endDate.getMonth() + 3);

// initializing fdatepicker
$('#dp1').fdatepicker({
  startDate: startDate,
  endDate: endDate,
  format: 'mm-dd-yyyy',
  disableDblClickSelection: true,
  leftArrow:'<<',
  rightArrow:'>>',
  closeIcon:'X',
  closeButton: true
});

lukaswojnar avatar Mar 15 '17 14:03 lukaswojnar