Calculate time difference using RadDateTimePicker

2 posts, 0 answers
  1. Pravallika
    Pravallika avatar
    30 posts
    Member since:
    Mar 2014

    Posted 19 Sep 2014 Link to this post

    Hai Alll.......

    i want to find difference between two dates differnce in hours and days using radatetimepicker in clent side how to do
  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 23 Sep 2014 Link to this post

    Hello Pravallika,

    You could try using the appraoch below:

    <telerik:RadDateTimePicker ID="rdtpAppointments_StartTime" SelectedDate='<%# Bind("StartedOn") %>' runat="server"> 
        <ClientEvents OnValueChanged="OnDateSelected" />
    <telerik:RadDateTimePicker ID="rdtpAppointments_EndTime" runat="server"/>

    function OnDateSelected(sender, eventArgs) { 
        var endTimePicker = $find("<%= rdtpAppointments_EndTime.ClientID %>"); 
        var newValue = new Date(eventArgs.get_newDate()); 
        var oldValue = new Date(eventArgs.get_oldDate()); 
        var difference = Math.round((newValue - oldValue) / 86400000); 
        var oldDate = new Date(endTimePicker.get_selectedDate()) 
        var newDate = oldDate.setDate(oldDate.getDate()+difference); 
        endTimePicker.set_selectedDate() = newDate;     

    Maria Ilieva

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top