This is a migrated thread and some comments may be shown as answers.

Calculate time difference using RadDateTimePicker

1 Answer 55 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Pravallika
Top achievements
Rank 1
Pravallika asked on 19 Sep 2014, 05:16 AM
Hai Alll.......

i want to find difference between two dates differnce in hours and days using radatetimepicker in clent side how to do

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 23 Sep 2014, 12:24 PM
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.

 
Tags
DataPager
Asked by
Pravallika
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or