Reputation: 8548
Can anyone guide me for formatting date in Bootstrap-DatePicker.
And I used Eternicode/bootstrap-datepicker. Here my codes at JSP..
<div>Date : </div>
<input type="text" style="width: 213px;" class="datepicker" >
And at my JavaScript file...
$('.datepicker').datepicker({
format: 'dd/mm/yyyy (D)',
autoclose: true,
keyboardNavigation : true ,
endDate : dateFormat(date, "dd/mm/yyyy (ddd)"),
daysOfWeekDisabled : [0]
});
Output that I want to get as like 27/07/2013 (Sat) .
But output that show from my code as 27/07/2013 (Sat
I can't see close bracket " ) ". Any Suggestions?
Upvotes: 22
Views: 164265
Reputation: 27
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: '»'
}
};
Upvotes: 1
Reputation: 37633
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'
})
Upvotes: 22
Reputation: 3735
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
Upvotes: 8
Reputation: 414
var type={
format:"DD, d MM, yy"
};
$('.classname').datepicker(type.format);
Upvotes: 3