简体   繁体   中英

Bootstrap-datepicker date with or without day

I'm using Bootstrap Datepicker

Is it possible to have multiple date formats? For example I have currently dd/mm/yyyy, but now theres need for mm/yyyy if no day specified.

I have found theres extraFormats option but it's just how it formats the date? Picker must allow to set date with or without day.

Code:

autoclose: true,
format: 'dd/mm/yyyy',
extraFormats: ['mm/yyyy'],
minViewMode: 'days',
startView: 'decade'

check this code

  $('.datepicker').datepicker({
        format: "mm-yyyy",
        startView: "months", 
        minViewMode: "months"
    });

refer this http://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate

See here: http://www.eyecon.ro/bootstrap-datepicker/ The example (5th) where it limits to months.

HTML

<div class="input-append date" id="dpMonths" data-date="102/2012" data-date-format="mm/yyyy" data-date-viewmode="years" data-date-minviewmode="months">
    <input class="span2" size="16" type="text" value="02/2012" readonly="">
    <span class="add-on"><i class="icon-calendar"></i></span>
</div>

JS

$('#dpMonths').datepicker();

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM