Hi,
I am facing an issue with the DateTimePicker where the time in the selection box is appearing up twice.Attached is the image.
The code that I have done for round off and for setting the max value is below, please let me know where i am going wrong.
Code snippet -
var
currentDate =
new
Date();
currentDate.setDate(currentDate.getDate() - 28);
currentDate.setMinutes(0);
var
startDateTimeElement = $(
"#start_dateTime"
);
startDateTimeElement.kendoDateTimePicker({
value: currentDate,
format:
"dd/MM/yyyy hh:mm tt"
,
culture:
"en-GB"
});
var
endDateTimeElement = $(
"#end_dateTime"
);
var
endDate =
new
Date();
//--rounding off the time to the nearest half an hour
var
mins = endDate.getMinutes();
var
quarterHours = Math.round(mins / 60);
if
(quarterHours === 2) {
endDate.setHours(endDate.getHours() + 1);
}
var
rounded = (quarterHours * 60) % 60;
endDate.setMinutes(rounded);
//--
endDateTimeElement.kendoDateTimePicker({
value: endDate,
format:
"dd/MM/yyyy hh:mm tt"
,
culture:
"en-GB"
});
startDateTimeElement.kendoDateTimePicker({
format:
"dd/MM/yyyy hh:mm tt"
,
culture:
"en-GB"
,
min: currentDate,
max: endDateTimeElement.data(
"kendoDateTimePicker"
).value(),
change:
function
() {
var
selectedDate = startDateTimeElement.data(
"kendoDateTimePicker"
).value();
endDateTimeElement.data(
"kendoDateTimePicker"
).min(selectedDate);
}
});
endDateTimeElement.kendoDateTimePicker({
format:
"dd/MM/yyyy hh:mm tt"
,
culture:
"en-GB"
,
min: startDateTimeElement.data(
"kendoDateTimePicker"
).value(),
max: endDate,
change:
function
() {
var
selectedDate = endDateTimeElement.data(
"kendoDateTimePicker"
).value();
startDateTimeElement.data(
"kendoDateTimePicker"
).max(selectedDate);
}
});