Datetimepicker: default time?

5 posts, 0 answers
  1. Sarah
    Sarah avatar
    7 posts
    Member since:
    May 2012

    Posted 14 Nov 2012 Link to this post

    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"?
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 15 Nov 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Eric
    Eric avatar
    5 posts
    Member since:
    Jul 2011

    Posted 01 Jul 2014 Link to this post

    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
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 02 Jul 2014 Link to this post

    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!
     
  6. Eric
    Eric avatar
    5 posts
    Member since:
    Jul 2011

    Posted 02 Jul 2014 in reply to Georgi Krustev Link to this post

    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
Back to Top
Kendo UI is VS 2017 Ready