Date Time Picker Not Working After Setting AutoUpdateInput To False
I have a requirement that when user has a date time exist in database only that time it shows date. But if database doesn't have date time then in text box it must be blank. But wh
Solution 1:
try this:
$("#reportdatetime").daterangepicker({
autoUpdateInput: false,
timePicker: true,
timePicker24Hour: true,
timePickerIncrement: 30,
locale: {
format: 'MM/DD/YYYY H:mm'
}
});
$('#reportdatetime').on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('MM/DD/YYYY H:mm') + ' - ' + picker.endDate.format('MM/DD/YYYY H:mm'));
});
$('#reportdatetime').on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
});
Solution 2:
You should trigger change()
to ensure it works perfectly in all cases; Sometimes you have some event listeners and need to trigger the change of date-range-picker.
$('#date-picker-input').daterangepicker({
autoUpdateInput: false,
singleDatePicker: true,
showDropdowns: true,
timePicker: true,
locale: {
format: 'DD-MM-YYYY hh:mm:ss'
},
});
$("#date-picker-input").on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY hh:mm A')).change();
});
$("#date-picker-input").on('cancel.daterangepicker', function(ev, picker) {
$(this).val('').change();
});
Solution 3:
You can try also this format if you want to get datetime picker with timerange in single formate. Below duetime is the id of your HTML input tag.
$("#duetime").daterangepicker({
autoUpdateInput: false,
startDate: false,
minYear: 1901,
showDropdowns: true,
singleDatePicker: true,
timePicker: true,
timePicker24Hour: false,
timePickerIncrement: 05,
drops:"up",
locale: {
// format: 'MM/DD/YYYY hh:mm A'
format: 'DD/MM/YYYY hh:mm A'
},
});
$("#duetime").on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('DD/MM/YYYY hh:mm A'));
});
$("#duetime").on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
});
Post a Comment for "Date Time Picker Not Working After Setting AutoUpdateInput To False"