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
    Admin
    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"> 
      <DateInput>
        <ClientEvents OnValueChanged="OnDateSelected" />
      </DateInput>
    </telerik:RadDateTimePicker>
     
    <telerik:RadDateTimePicker ID="rdtpAppointments_EndTime" runat="server"/>

    JS:
    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;     
      }


    Regards,
    Maria Ilieva
    Telerik
     

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top