单击时更改日期时间选择器上的日期
change the date on the datetimepicker when clicking
我想显示现有数据的日期,然后我想在点击输入文本时显示日期,显示我设置的日期但是没有用怎么办?
<input type="text" name="start" id="start_date" value="2017-12-05"/>
$('#start_date').datetimepicker({
format: 'YYYY-MM-DD',
});
$('#start_date').datetimepicker().on('dp.change', function (e) {
var dt = "2017-12-12"
$('#start_date').data('DateTimePicker').minDate(incrementDay);
});
所以当我想 select 一个新日期 date minDate on 2017-12-12
我们必须在 minDate
方法中使用日期格式。有帮助吗
var incrementDay = 7;
$('#start_date').datetimepicker({
format: 'YYYY-MM-DD',
});
$('#start_date').one('click',function(){
var start_date = $('#start_date').data('DateTimePicker');
var stDate = new Date(start_date.date());
var newDate = new Date();
newDate.setDate(stDate.getDate() + incrementDay)
start_date.minDate(newDate);
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<div style="position: relative">
<input type="text" name="start" id="start_date" value="2017-12-05" />
</div>
我想显示现有数据的日期,然后我想在点击输入文本时显示日期,显示我设置的日期但是没有用怎么办?
<input type="text" name="start" id="start_date" value="2017-12-05"/>
$('#start_date').datetimepicker({
format: 'YYYY-MM-DD',
});
$('#start_date').datetimepicker().on('dp.change', function (e) {
var dt = "2017-12-12"
$('#start_date').data('DateTimePicker').minDate(incrementDay);
});
所以当我想 select 一个新日期 date minDate on 2017-12-12
我们必须在 minDate
方法中使用日期格式。有帮助吗
var incrementDay = 7;
$('#start_date').datetimepicker({
format: 'YYYY-MM-DD',
});
$('#start_date').one('click',function(){
var start_date = $('#start_date').data('DateTimePicker');
var stDate = new Date(start_date.date());
var newDate = new Date();
newDate.setDate(stDate.getDate() + incrementDay)
start_date.minDate(newDate);
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<div style="position: relative">
<input type="text" name="start" id="start_date" value="2017-12-05" />
</div>