Bootstrap datetimePicker月视图

时间:2016-01-29 10:41:53

标签: format datetimepicker

我已经在我的网站上集成了bootstrap datetimepicker,并进行了一些个性化设置。 问题是,当我选择月份格式时,我有3行具有不同的月数 4-5-3 我想将每4个月放在一行中。有帮助吗?

的JavaScript

var currentTime = new Date()
var minDate = new Date(currentTime.getFullYear(), currentTime.getMonth());

//init dateTimePicker
var params = {
  locale: 'fr',
  clear: "Clear",
  useCurrent: true,
  minDate: minDate,
  stepping: 5,
  format: 'MM/YYYY',
  icons: {
    previous: '',
    next: ''
  },
  inline: false
}

screenshot of the timePicker

1 个答案:

答案 0 :(得分:0)

试试这个

<div class="row">
  <div class="col-md-12">
    <h6>Datetimepicker</h6>
    <div class="form-group">
      <div class="input-group date" id="datetimepicker">
        <input type="text" class="form-control" /> <span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
      </div>
    </div>
  </div>

<强>的JavaScript

$(function() {
  var date = new Date();
  var currentMonth = date.getMonth();
  var currentDate = date.getDate();
  var currentYear = date.getFullYear();  
  $('#datetimepicker').datetimepicker({
    locale: 'fr',
    clear: "Clear",
    useCurrent: true,
    minDate: new Date(currentYear, currentMonth, currentDate),
    stepping: 5,
    format: 'MM/YYYY',
    icons: {
      previous: '',
      next: ''
    }
  });
});

Demo on fiddle