This is a migrated thread and some comments may be shown as answers.

Datetimepicker: default time?

4 Answers 1462 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Sarah
Top achievements
Rank 1
Sarah asked on 14 Nov 2012, 08:39 PM
Is there a way to enforce a default time selection when a user selects a date? Currently, when a user selects a date, "12:00 AM" is displayed in the textarea. Is there a way to set it up so it might be something like "11:30 PM"?

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 15 Nov 2012, 03:26 PM
Hello Sarah,

 
The DateTimePicker widget persist the time part of the Date object, if a value is set though the initialization of the widget. When create a new Date, like this:

new Date(2000, 10, 10); -> time is 12:00 AM
the time portion will be 12:00 AM. This is the default behavior of the Date and that is why when the end user selects a day from the Calendar the time is midnight. If you need to define default time for the DateTimePicker, you will need to set a value to the widget. Check this jsBin demo.

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Eric
Top achievements
Rank 1
answered on 01 Jul 2014, 12:49 PM
If I may ask a question regarding your jsBin Demo, I noticed that when you enter in the month portion of the new Date() function, the month shown in the KendoUI DateTimePicker is always a month ahead.  I have to enter in the month value with a "- 1" attached to it for the correct month to show.  Is this a quirk of Javascript or of the Kendo control?

See the attached screenshot and look at month value entered and what is actually showing.

Thanks,
Eric Dickey
0
Georgi Krustev
Telerik team
answered on 02 Jul 2014, 08:15 AM
Hello Eric,

The JavaScript Date accepts ​​zero based value ​for month parameter. I would suggest you check the documentation of JavaScript Date object.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Eric
Top achievements
Rank 1
answered on 02 Jul 2014, 11:50 AM
Georgi,
 Thanks for the response.  After 15 years of programming, I am just now having to deal with javascript, having developed mostly for the desktop and wasn't aware of that.  Thanks again.

Eric
Tags
Date/Time Pickers
Asked by
Sarah
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Eric
Top achievements
Rank 1
Share this question
or