title: Get difference in days of two different dates in same ASPxDateEdit Control with javascript
body: <p>I have an <code>ASPxDateEdit</code> control with this code:</p>
  
  <pre><code>&lt;dx:ASPxDateEdit ID="dtPayDate" ClientInstanceName="dateEdit" EditFormatString="yyyy-MM-dd" DisplayFormatString="yyyy-MM-dd" runat="server" EnableClientSideAPI="true" CssClass="form-control"&gt;
  &lt;ClientSideEvents Init="FirstDate()" LostFocus="ChangeDate()" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>And two events:</p>
  
  <pre><code>var InititalPay;
  var FinalPay;
  
  function FirstDate(s, e) {
      var date = s.GetDate();
      var dd = date.getDate();
      var mm = date.getMonth();
      var yy = date.getFullYear();
      InitialPay = new Date(yy + ',' + mm + ',' + dd);
  }
  
  function ChangeDate() {
      var jsDate = dateEdit.GetDate();
      var year = jsDate.getFullYear(); // where getFullYear returns the year (four digits)
      var month = jsDate.getMonth(); // where getMonth returns the month (from 0-11)
      var day = jsDate.getDate(); // where getDate returns the day of the month (from 1-31)
      FinalPay = new Date(year + ',' + month + ',' + day);
  
      var a = moment([FinalPay]);
      var b = moment([InitialPay]);
      days = a.diff(b, 'days') // diferencia en dias
      alert(days)
  }
  </code></pre>
  
  <p>I need to get the date before change and store in a var. Next get the date changed and store it into other var. Get the difference of two dates. I'm using <code>moment.js</code> too but if exists other method I can use it.</p>