Custom Date Format for Bootstrap-DatePicker

Custom Date Format for Bootstrap-DatePicker

Can anyone guide me for formatting date in Bootstrap-DatePicker.
And I used Eternicode/bootstrap-datepicker.
Here my codes at JSP..

Date :

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 ? Thanks in advance for all…

Solutions/Answers:

Solution 1:

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

Solution 2:

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'
})

Solution 3:

var type={
      format:"DD, d MM, yy"
};
$('.classname').datepicker(type.format);

Solution 4:

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: '»'
    }
};

Related:  Submit form data both on clicking enter and hitting the submit button from a Bootstrap modal window

References