Bootstrap Datepicker Date Range. Now I am getting DateFormat as mm/dd/yyyy. but I need to change this to dd/mm/yyyy. Can anyone please help me on this.?
$(document).ready(function () {
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
var checkin = $('#AvailableFrom').datepicker({
onRender: function (date) {
date = new Date();
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
if (ev.date.valueOf() > checkout.date.valueOf()) {
var newDate = new Date(ev.date);
newDate.setDate(newDate.getDate() + 1);
checkout.setValue(newDate);
}
checkin.hide();
$('#AvailableTo')[0].focus();
}).data('datepicker');
var checkout = $('#AvailableTo').datepicker({
onRender: function (date) {
return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
checkout.hide();
}).data('datepicker');
});
You can make use of format
option of bootstrap datepicker.
var checkin = $('#AvailableFrom').datepicker({
format: "dd/mm/yyyy", // here you can update the date format
onRender: function (date) {
date = new Date();
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
});
JSFiddle with a simple example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.