tamble / jquery-ui-daterangepicker

A JQuery UI based date range picker.
MIT License
184 stars 108 forks source link

default selected range #7

Closed MiloZ closed 9 years ago

MiloZ commented 9 years ago

Hi,

Is it possible to have a range selected on load, for instance have "month to date" displayed when the page is loaded?

Thanks

op16 commented 9 years ago

Hi,

There is no option at the moment to simply select one of the preset ranges (it would be nice to have though).

But there are two posible solutions:

$("#yourId").daterangepicker("setRange", {start: moment().startOf('month').startOf('day').toDate(), end: moment().startOf('day').toDate()});

<input id='yourId' value='{"start":"2015-02-01","end":"2015-02-19"}'>

(it needs proper html quoting, but you got the ideea)

MiloZ commented 9 years ago

Thank you!