如何设置minDate 2

时间:2016-05-25 12:08:31

标签: jquery datetimepicker

我想突出显示日期后的日期,我正在使用以下代码但不能正常工作。

{
  "mappings": {
    "search_data": {
      "properties": {
        "main_array": {
          "properties": {
            "location": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  }
}

1 个答案:

答案 0 :(得分:2)

将minDate值设置为Date对象

var date = new Date(); // get current date
date.setDate(date.getDate() + 2); // add two days to it
$('#date').datetimepicker({
  timepicker: false,
  format: 'Y-m-d',
  formatDate: 'Y-m-d',
  minDate: date,
  scrollDay: false,
  scrollMonth: false,
  scrollYear: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.css" rel="stylesheet" />
<input id="date" />
或者像the documentation set '+1970/01/03'中的最后日期到后天

$('#date').datetimepicker({
  timepicker: false,
  format: 'Y-m-d',
  formatDate: 'Y-m-d',
  minDate: '+1970/01/03',
  scrollDay: false,
  scrollMonth: false,
  scrollYear: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.css" rel="stylesheet" />
<input id="date" />