It seems that the plugin only accepts a specific date format for minDate and maxDate , which is mm/dd/yyyy .
Just using new Date(); Unfortunately, it does not work, because it returns a full date, which is incorrect in the format.
It seems to me that the code below works, it will always use it as min and +30 as max.
function getFormatDate(d){ return d.getMonth()+1 + '/' + d.getDate() + '/' + d.getFullYear() } $(document).ready(function() { var minDate = getFormatDate(new Date()), mdTemp = new Date(), maxDate = getFormatDate(new Date(mdTemp.setDate(mdTemp.getDate() + 30))); $('#daterange').daterangepicker( { minDate: minDate, maxDate: maxDate } ); });
source share