1

I know how to set a default date using either the current date or a fixed date. But how can I get the calendar to display the date that already may exist my date field?

I.e. if the date in the field is 09/15/2001 how can I get the calendar to go to that date when it opens?

theDaviator
  • 37
  • 1
  • 9

1 Answers1

0
$('#datepicker').datepicker('setStartDate', '2012-01-01');

More info here: Bootstrap DatePicker, how to set the start date for tomorrow?

Community
  • 1
  • 1
Vincent
  • 204
  • 1
  • 12
  • That sets a fixed date but does not use the date value already in the field. Again, it's not so much about setting the date but what date is displayed when the calendar opens. – theDaviator Nov 11 '16 at 19:31
  • Maybe the startView? – Vincent Nov 11 '16 at 19:37
  • https://github.com/uxsolutions/bootstrap-datepicker/blob/ca11c450/README.md#startview – Vincent Nov 11 '16 at 19:37
  • that is where it is set but I cannot get it to take a variable or find any other way to pass the value that does not break the datepicker. I need something like: ` ' – theDaviator Nov 11 '16 at 19:49
  • So you need to get the date from the field in the right date format. – Vincent Nov 11 '16 at 19:55
  • Something like defaultDate: $('.myField').val() – Vincent Nov 11 '16 at 19:57