JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css">
<script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<div class="datepicker" id="datepicker1"></div>
JavaScript
$(function () {
$('.datepicker').datepicker({
format: 'yyyy-mm-dd',
multidate: true,
multidateSeparator: ",",
calendarWeeks: true,
todayHighlight: true
}).on('changeDate', function (e) {
var selecteddates = $('.datepicker').datepicker('getDates');
var formatedSelectedDates = [];
for (var date in selecteddates) {
formatedSelectedDates.push(convertDate(selecteddates[date]));
}
alert(formatedSelectedDates);
});
});
function convertDate(d) {
function pad(s) {
return (s < 10) ? '0' + s : s;
}
return [d.getFullYear(), pad(d.getMonth() + 1), pad(d.getDate())].join('-');
}