Default Date issue for RadDateTimePicker

2 posts, 0 answers
  1. Pradeep Enugala
    Pradeep Enugala avatar
    55 posts
    Member since:
    Apr 2010

    Posted 23 Apr 2012 Link to this post

    By default RadDateTimePicker taking Today date whenever select time from timepicker.

    Expected Behavior:
    Suppose today date is 23-Apr-2012.When we choose time(7:00 PM) for the first time it should selected as "XX-Apr-2012 7:00 PM" instead "23-Apr-2012 7:00 PM". 

    Note: 'XX' could be any date.It is purely situational.

    Can it possible to change default behavior to expected date ???

  2. Eyup
    Eyup avatar
    2941 posts

    Posted 25 Apr 2012 Link to this post

    Hello Pradeep,

    DatePicker loads the present day upon selecting a Time value, because it is declared as its focused day by default.
    To change that and define a custom initial Date, please use the OnClientTimeSelected event of the TimePicker:
    <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server"
    function timeSelected(sender, args) {
     if (args.get_oldTime() == null) {
      var dateTimePicker = $find("<%=RadDateTimePicker1.ClientID %>");
      var selectedDate = args.get_newTime().toString();
      var index = selectedDate.indexOf(":");
      var hours = selectedDate.substring(index - 2, index);
      var minutes = selectedDate.substring(index + 1, index + 3);
      dateTimePicker.set_selectedDate(new Date("01/01/2012/" + hours + ":" + minutes));

    It works properly on my end. Please give it a try and let me know what is the result

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top