Bootstrap datepicker example with event

Nowaday peoples are using bootstrap date picker. it is very easy to  use. Many admin theme are made in bootstrap.

Below is the example code of bootstreap detepicker with changeDate event.

$('#div_id').datepicker({
autoclose: true,
format: 'dd-mm-yyyy',
startDate: '-3d'
}).on("changeDate", function (e) {
// `e` here contains the extra attributes
var day = e.date.getDate();
var month = e.date.getMonth();
var year = e.date.getFullYear();
month = month + 1;
if(month < 10) {
month = "0" + month;
}
var full_date = year + "-" + month + "-" + day;
});
}

To read more about bootstrap datepicker click on this link

https://bootstrap-datepicker.readthedocs.io/en/latest/events.html#changedate

 

Leave a Reply

Your email address will not be published. Required fields are marked *

sixteen − 10 =