Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Calendar > RadTimePicker add hours with client side api

Not answered RadTimePicker add hours with client side api

Feed from this thread
  • Jacob avatar

    Posted on Jan 12, 2012 (permalink)

    How do I add hours to the current time on the RadTimePicker control?

    Currently my 'End' RadTimePicker automatically defaults to the 'Start' time RadTimePicker when the user selects the Start time. My desired output is for the End RadTimePicker to automatically default the the Start time RadTimePicker, plus one hour, when the user selects the Start time.

    Thanks for any help :)

    Reply

  • jumpstart Master avatar

    Posted on Jan 16, 2012 (permalink)

    Jacob:

    Would it be possible for you to paste your code and a screen shot of your application. This would make it easier to understand your requirement and to help me to assist you.

    Cheers!

    Reply

  • Jacob avatar

    Posted on Jan 18, 2012 (permalink)

    function radStartTime_OnDateSelected(pickerInstance, args)
    {
         var radStartTimePicker = $find('<%= radStartTime.ClientID%>');
         var radEndTimePicker = $find('<%= radEndTime.ClientID%>');
         radEndTimePicker.set_selectedDate(radStartTimePicker.get_selectedDate());
    }

    Reply

  • Vasil Vasil admin's avatar

    Posted on Jan 20, 2012 (permalink)

    Hello Jacob,

    The get_selectedDate is returning a Date JavaScript object so you could use it's functions to manipulate it.
    For example you could use setHours to add one more hour.
    currentDateTime = $find("<%= radStartTime.ClientID%>").get_selectedDate();
    nextDateTime = new Date(currentDateTime);
    nextDateTime.setHours(currentDateTime.getHours() + 1);
    radEndTimePicker.set_selectedDate(nextDateTime);
    Note that you will need additional check if the current hour is 23.

    There are other solutions as well, please check this forum:
    http://stackoverflow.com/questions/1050720/adding-hours-to-javascript-date-object

    All the best,
    Vasil
    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Calendar > RadTimePicker add hours with client side api
Related resources for "RadTimePicker add hours with client side api"

ASP.NET Calendar Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]