Start and End Dates

I can't figure out how to calculate the duration in a start-date to end-date. Once Calendar options are selected, you have the option for stat and end dates, I ned an auto calculation to workout the duration.

Any ideas?


$(document).on('knack-view-render.view_29', function(event, view, data) {

  document.getElementById("field_63").readOnly = true;

  $(document).on("change load input click", "#kn-input-field_60 input", function(){

   var startDate = $("#view_29-field_60").val().split("/");

   var endDate = $("#view_29-field_60-to").val().split("/");


    startDate = new Date(startDate[2],startDate[1],startDate[0]);

    endDate = new Date(endDate[2],endDate[1],endDate[0]);

    var timeDiff = Math.abs(endDate.getTime() - startDate.getTime());

 var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));






Here's how I did it to output the number of days into a new field, just replace the views and fields as necessary, not really optimized at all but functioning

Same problem.

I need to calculate the duration of calendar events...