Custom Date Format for Bootstrap-DatePicker

前端 未结 4 475
生来不讨喜
生来不讨喜 2020-12-29 05:48

Can anyone guide me for formatting date in Bootstrap-DatePicker.

And I used Eternicode/bootstrap-datepicker. Here my codes at JSP..



        
相关标签:
4条回答
  • 2020-12-29 05:57

    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

    0 讨论(0)
  • 2020-12-29 06:01

    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'
    })
    
    0 讨论(0)
  • 2020-12-29 06:07

    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: '»'
        }
    };
    
    0 讨论(0)
  • 2020-12-29 06:13
    var type={
          format:"DD, d MM, yy"
    };
    $('.classname').datepicker(type.format);
    
    0 讨论(0)
提交回复
热议问题