Using Bootstrap Datepicker Internationally

94 views Asked by At

I've been building an app that needs to work internationally. In this app, I'm using the Bootstrap Datepicker. I am able to successfully initializing a date picker using the following:

<input id="myDatePicker" class="form-control input-sm" type="text" autocomplete="off" value="">

$('#myDatePicker').datepicker({
  autoclose: true,
  clearBtn: true,
  language: 'zh-CN',
  startDate: '01/01/1900',
  todayHighlight: true
});

When a user chooses a date, it correctly gets displayed in Chinese. My problem is, sometimes when the page loads, I need to pre-select the date. If I wanted myDatePicker to already be selected to June 1, in Chinese, what value do I need to put in the value attribute of the input element.

Due to the way the code is structured, I cannot set the value in the .datepicker initialization code. I need to set the value in the value attribute of the input element.

Thank you

1

There are 1 answers

0
msdedwards On BEST ANSWER

From what the docs say here the following format is acceptable:

"06-01-2012"

Making your HTML look like so:

<input id="myDatePicker" class="form-control input-sm" type="text" autocomplete="off" value="06-01-2015">