我有这个例子
$('#datepicker').daterangepicker({
timePicker: true,
startDate: new Date(),
endDate: new Date(),
locale: {
format: 'MM/DD/YYYY HH:mm'
}
}, function(start, end, label) {
$("#range1").val(start.format('MM/DD/YYYY HH:mm:00')+" - "+end.format('MM/DD/YYYY HH:mm:00'));
});
如何将daterangepicker动态更改为datepicker?
答案 0 :(得分:1)
只需在代码中添加:“ singleDatePicker:true”即可
$('#datepicker').daterangepicker({
singleDatePicker: true,
timePicker: true,
startDate: new Date(),
endDate: new Date(),
locale: {
format: 'MM/DD/YYYY HH:mm'
}
}, function(start, end, label) {
$("#range1").val(start.format('MM/DD/YYYY HH:mm:00')+" - "+end.format('MM/DD/YYYY HH:mm:00'));
});
文档:http://www.daterangepicker.com/#example3
您可以在此处测试所有变量:http://www.daterangepicker.com/#config
答案 1 :(得分:0)
从代码中删除时间字段,如
$('#datepicker').daterangepicker({
timePicker: true,
startDate: new Date(),
endDate: new Date(),
locale: {
format: 'MM/DD/YYYY'
}
}, function(start, end, label) {
$("#range1").val(start.format('MM/DD/YYYY')+" - "+end.format('MM/DD/YYYY'));
});
希望它适合你