title: Date format conversion from dd-MMM-yyyy to dd-MM-yyyy in javascript
body: <p>I am trying to compare start date and end date in jquery. Code in aspx page looks like: </p>
  
  <pre><code>&lt;asp:TextBox ID="tbStartDate" runat="server" CssClass="textbox" Width="80px" contentEditable="false" onchange="javascript:compareDates();"&gt;&lt;/asp:TextBox&gt;
  
  &lt;asp:ImageButton runat="Server" ID="ibStartCalendar" ImageUrl="~/Images/calendar.jpg"
   Height="18px" AlternateText="Click to show calendar" /&gt;
  
  &lt;act:CalendarExtender ID="ceStartDate"  runat="server" Format="dd-MMM-yyyy" TargetControlID="tbStartDate" PopupButtonID="ibStartCalendar" CssClass="Calendar"&gt;
  &lt;/act:CalendarExtender&gt;
  </code></pre>
  
  <p>And javascript function:</p>
  
  <pre><code>function compareDates() {
    var start = $("#&lt;%=tbStartDate.ClientID %&gt;").val();
    var end = $("#&lt;%=tbEndDate.ClientID %&gt;").val();
  
    if (!compareDate(start, end)) { 
  $("#&lt;%=lblMsg.ClientID %&gt;").html("Start Date can not be greater than End Date");
                      }
    }
   function compareDate(start, end) {
      if (start.length &gt; 0 &amp;&amp; end.length &gt; 0) {
          var stDate = new Date(start);
          var enDate = new Date(end);
          var compDate = enDate - stDate;
  
          if (compDate &gt;= 0)
              return true;
          else {
              return false;
          }
      } else { return true; }
  }
  </code></pre>
  
  <p>Requirement is to dispaly date in "dd-MMM-yyyy" format in text boxes to I can not change format in calenderExtender.</p>
  
  <p>When I keep this format star date and end date becomes "NaN". If I change format in calenderExtender i get proper results. However as I said I can not change format there. How can I change format in javascript?</p>