Reputation: 842
I want to use the datepicker with a specific default date, but somehow this doesn't work:
<input class="cal-datepicker" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true" data-date-today-highlight="true" data-date-default-view-date="01/01/2015">
How can I get it to work?
Upvotes: 0
Views: 7053
Reputation: 48357
You could try this:
$('.cal-datepicker').datepicker("update", new Date());
Upvotes: 1
Reputation: 1600
I solved my problem by setting the 'useCurrent' property to 'false', and then set the date after initialization:
$('#datepicker').datepicker({
useCurrent: false,
format: 'dd/mm/yyyy'
});
$('#datepicker').datepicker('setDate', '01/01/2017');
Upvotes: 2
Reputation: 620
As this answer says, you have to use the setDate function of the datepicker library. Like this:
$('#datepicker').datepicker('setDate', new Date()); // = set to today
Upvotes: 5