Bootstrap DatePicker setDate method not updating the calendar

I set the value of bootprap datepicker using the provided setValue method.

for instance

 tripToDatePicker.setValue(tripFromDatePicker.date); 

But for some reason the calendar is not updating

enter image description here

+6
source share
2 answers

Edit:

http://www.eyecon.ro/bootstrap-datepicker/ is not very documented, you should try http://eternicode.imtqy.com/bootstrap-datepicker/ .

anyway the code below will work for you

 $("#dp1").datepicker("update", "02-16-2012"); 

or

 $("#dp1").datepicker("setValue", "02-17-2012"); 

where "#dpi" is the identifier of the text field that uses datepicker.

+6
source

'setValue' is replaced by 'setDate'.

Using a string as input for setDate can be tricky. It must match dateformat, otherwise you may get unexpected results. It is safer to create a "new date (y, m, d)" from your input, for example. new date (2015,3,10) for "April 10, 2015." It will always work.

When using a date representation in seconds, for example. 1428659901, then use the new date (value * 1000). ' Note that the datepicker will use any value here, but will only show the selected date on the calendar if the hours, minutes and seconds are 0. It took some time to figure this out.

+6
source

Source: https://habr.com/ru/post/972952/


All Articles