Get datetime picker value for jquery

1 Answer 100 Views
Date/Time Pickers
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
Taras asked on 01 Oct 2024, 09:41 PM

I have a datepicker in a view 

@(Html.DatePickerFor(model => model.EventDate)
     .Format("{0:dd/MM/yy}")
)

I need to retrieve the date from the datepicker to use as the minimum value for a datetimepicker in a list view. 


		shiftStart.kendoDateTimePicker({
			timeFormat: "HH:mm",
			format: "dd/MM/yyyy HH:mm",
			// min: new Date(vYear, vMonth - 1, vDay, vHour, vMinute),
			interval: { minutes: 15 }
		});

How do I get that value?

Taras
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 03 Oct 2024, 04:10 PM

Disregard last question.  Found a sample.  Internal doesn't require the {} if only one component.

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 03 Oct 2024, 01:27 PM

Hello,

You can use the DatePicker's value() client-side API method, to get the date selected in it:

//get a reference to the DatePicker's instance:
var datepicker = $("#EventDate").data("kendoDatePicker");
//note that the name of the field the picker is bound to is used to get a proper reference

//call the value() method to get the date selected in the component:
var dateValue = datepicker.value();
console.log(dateValue);


Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Taras
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 03 Oct 2024, 04:02 PM

Ivan, Thanks.

Another related question.  I need to have the minute part in 15 minute increments.  When I use the following code, it does not show a drop down of times, just 00:00.

shiftStart.kendoDateTimePicker({
componentType: "classic",
timeFormat: "HH:mm",
format: "dd/MM/yyyy HH:mm",
min: eventDate,
interval: { minutes: 15 }
});


shiftStart.kendoDateTimePicker({
	componentType: "classic",
	timeFormat: "HH:mm",
	format: "dd/MM/yyyy HH:mm",
	min: eventDate,
	interval: { minutes: 15 }
});

If I exclude the interval, the time drop down show intervals of 30 minutes.  Same occurs if omit componentType.

How do I get a 15 minute interval?

 

Taras
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 03 Oct 2024, 04:11 PM

This is the question to disregard
Tags
Date/Time Pickers
Asked by
Taras
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Ivan Danchev
Telerik team
Share this question
or