I use this date picker. I need input to be empty on page loading, but set default value to today on datepicke popap. Now when I jast write:
$(".dp").datepicker({
format: 'dd.mm.yyyy',
startDate: '01.01.2012',
endDate: ''
});;
It's first Janary 1970 by default when datapicker is popuping. How can I change default value?
quick but works
In bootstrap-datepicker.js (~ Line 331) change:
to
You can do it from the
show
event, but I have to say that datepicker's documentation is really lacking. Here's how:Naturally, where I have
01.05.2012
, put the actual date.If anyone runs into this, where they want the default value in the input value to show as well as initialize datetimepicker, this works for me. I set the value in the html to data-val and check for that in the ready function. Then, I use moment to covert the string and set the initial picker value: