title: how to parse a "dd/mm/yyyy" or "dd-mm-yyyy" or "dd-mmm-yyyy" formatted date string using JavaScript or jQuery
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3003355/extending-javascripts-date-parse-to-allow-for-dd-mm-yyyy-non-us-formatted-date">Extending JavaScript&#39;s Date.parse to allow for DD/MM/YYYY (non-US formatted dates)?</a><br>
    <a href="https://stackoverflow.com/questions/7151543/convert-dd-mm-yyyy-string-to-date">Convert dd-mm-yyyy string to date</a>  </p>
  </blockquote>
  
  
  
  <p>Entered a date in textbox, for example: <em>05/09/1985</em>, and I wanted to convert it to <em>05-Sep-1985</em> (dd-MMM-yyyy) format. How would I achieve this? Note that the source format may be <code>dd-mm-yyyy</code> or <code>dd/mm/yyyy</code> or <code>dd-mmm-yyyy</code> format.</p>
  
  <p><strong>Code Snippet:</strong></p>
  
  <pre><code> function GetDateFormat(controlName) {
          if ($('#' + controlName).val() != "") {      
              var d1 = Date.parse($('#' + controlName).val());
              if (d1 == null) {
                  alert('Date Invalid.');
                  $('#' + controlName).val("");
              }
                  var array = d1.toString('dd-MMM-yyyy');
                  $('#' + controlName).val(array);
          }
      }
  </code></pre>
  
  <p>This code returns <em>09-May-1985</em> but I want <em>05-Sep-1985</em>. Thanks.</p>