时间选择器在选择的时候,同时配置了另一个时间选择器内的参数
<div class="form-group">
<label for="exampleInputName2">停留时间:</label>
<input type="text" class="form-control" name="open" id="start_time" placeholder="点击选择开始时间" required>
</div>
<div class="form-group">
<label for="exampleInputEmail2">到</label>
<input type="text" class="form-control" name="close" id="end_time" placeholder="点击选择结束时间" required>
</div>
<script src="{{asset('/js/laydate.js')}}"></script>
<script>
var startDate = laydate.render({
elem: '#start_time',
type: 'datetime',
format: 'yyyy-MM-dd HH:mm:ss',
done: function(value, date){
endDate.config.min ={
year:date.year,
month:date.month-1,
date: date.date,
hours: 0,
minutes: 0,
seconds : 0
};
}
});
var endDate = laydate.render({
elem: '#end_time',
type: 'datetime',
format: 'yyyy-MM-dd HH:mm:ss',
done: function(value,date){
startDate.config.max={
year:date.year,
month:date.month-1,//注意是month-1,写在date上的话你后边的日期选择不了
date: date.date,
hours: 0,
minutes: 0,
seconds : 0
}
}
});
</script>