Can anyone guide me for formatting date in Bootstrap-DatePicker.
And I used Eternicode/bootstrap-datepicker. Here my codes at JSP..
I'm sure you are using a old version. You must use the last version available at master branch:
https://github.com/eternicode/bootstrap-datepicker
Perhaps you can check it here for the LATEST version always
http://bootstrap-datepicker.readthedocs.org/en/latest/
$('.datepicker').datepicker({
format: 'mm/dd/yyyy',
startDate: '-3d'
})
or
$.fn.datepicker.defaults.format = "mm/dd/yyyy";
$('.datepicker').datepicker({
startDate: '-3d'
})
I solve it editing the file bootstrap-datapicker.js.
Look for the text bellow in the file and edit the variable "Format:"
var defaults = $.fn.datepicker.defaults = {
assumeNearbyYear: false,
autoclose: false,
beforeShowDay: $.noop,
beforeShowMonth: $.noop,
beforeShowYear: $.noop,
beforeShowDecade: $.noop,
beforeShowCentury: $.noop,
calendarWeeks: false,
clearBtn: false,
toggleActive: false,
daysOfWeekDisabled: [],
daysOfWeekHighlighted: [],
datesDisabled: [],
endDate: Infinity,
forceParse: true,
format: 'dd/mm/yyyy',
keyboardNavigation: true,
language: 'en',
minViewMode: 0,
maxViewMode: 4,
multidate: false,
multidateSeparator: ',',
orientation: "auto",
rtl: false,
startDate: -Infinity,
startView: 0,
todayBtn: false,
todayHighlight: false,
weekStart: 0,
disableTouchKeyboard: false,
enableOnReadonly: true,
showOnFocus: true,
zIndexOffset: 10,
container: 'body',
immediateUpdates: false,
title: '',
templates: {
leftArrow: '«',
rightArrow: '»'
}
};
var type={
format:"DD, d MM, yy"
};
$('.classname').datepicker(type.format);