title: convert various date formats to yyyy-mm-dd in javascript
body: <p>I want to be able to convert various date formats to a single format, i.e.to yyyy-mm-dd , so for example:</p>
  
  <pre><code>20-10-1975 -&gt; 1975-10-20 (dd-mm-yyyy -&gt; yyyy-mm-dd) 
  
  01-25-1961 -&gt;1961-01-25 (mm-dd-yyyy -&gt; yyyy-mm-dd) 
  
  1991-10-25 -&gt; 1991-10-25 (yyyy-mm-dd remains yyyy-mm-dd)
  </code></pre>
  
  <p>if possible also with the time component, so for example:</p>
  
  <pre><code>20-10-1975 13:15:22 -&gt; 1975-10-20 13:15:22
  </code></pre>
  
  <p>The reason is I want to be able to sort an array on dates, but sometimes I have to deal with various formats which I don't control.</p>
  
  <p>Is there a function to achieve this?</p>
  
  <p>PS I am aware that sometime a date can be ambiguous, for example 6-5-2015 can be 6th of May, or 5th of June, but I am fine with this as long as the sorting works.  </p>