Im using bootstrap datepicker and I'm applying the set date function.
ie.,
$('.datepicker').datepicker('setDate', new Date(2011, 2, 5));
This works fine but the date specified is not getting selected.
$(". selector"). datepicker( {defaultDate:"+6"} );
You must FIRST call datepicker() > then use 'setDate' to get the current date. $(". date-pick").
After selecting the date using setDate
method, you need to update the datepicker
in order to get the selected date in datepicker
.
Before:
$('#datepicker').datepicker('setDate', new Date(2011, 2, 5));
$('#datepicker').datepicker('update'); //update the bootstrap datepicker
Finally:
Im using bootstrap datepicker. below code worked for me:
$('#my-datepicker').datepicker('setDate', 'now');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With