[英]Bootstrap Date Range Picker -> Single Date Picker: How to set a Date
I'm experimenting with Boootstrap Date Range Picker我正在试验Boootstrap 日期范围选择器
Whats the best way to set Date into a Single Date Picker via Javascript?通过 Javascript 将日期设置为单个日期选择器的最佳方法是什么?
Single Date Picker initialization code单一日期选择器初始化代码
$(#date).daterangepicker({
locale: {
format: 'DD/MM/YYYY',
},
singleDatePicker: true,
showDropdowns: true
});
I tried with below code:我尝试使用以下代码:
$("date").data('daterangepicker').setStartDate(data.startDate);
This way, I'm getting below output, which is not really acceptable!!!这样,我的输出就低于输出,这是不可接受的!!!
Hope someone come up with a nice solution.希望有人想出一个好的解决方案。
Cheers!!干杯!!
Try尝试
$("date").data('daterangepicker').setStartDate(data.startDate);
$("date").data('daterangepicker').setEndDate(data.startDate);
That is the only way I can find so far.到目前为止,这是我能找到的唯一方法。
Try this:试试这个:
Set Date:设置日期:
$(#date).daterangepicker({
locale: {
format: 'DD/MM/YYYY',
},
singleDatePicker: true,
showDropdowns: true,
startDate: '2020/03/04',
startDate: '2020/03/04'
});
Reset date:重置日期:
$("#date").data('daterangepicker').setStartDate('2020/03/04');
$("#date").data('daterangepicker').setEndDate('2020/03/04');
If u gonna reset current date:如果你要重置当前日期:
$("#date").data('daterangepicker').setStartDate(moment());
$("#date").data('daterangepicker').setEndDate(moment());
I had the same issue, in my case.就我而言,我遇到了同样的问题。 The issue was in the startDate format, it was not matching with the format given in locale:{format:'DD/MM/YYYY'}
问题出在 startDate 格式,它与 locale:{format:'DD/MM/YYYY'} 中给出的格式不匹配
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.