title: Cleaner way to convert dd-mm-yyyy to mm-dd-yyyy format in Javascript
body: <p>I have this date as string with me 15-07-2011 which is in the format <code>dd-mm-yyyy</code>. I needed to create a <code>Date</code> object from this string. So I have to convert the date in <code>dd-mm-yyyy</code> to <code>mm-dd-yyyy</code> format.</p>
  
  <p>What I did is the following.  </p>
  
  <pre><code>var myDate = '15-07-2011';
  var chunks = myDate.split('-');
  
  var formattedDate = chunks[1]+'-'+chunks[0]+'-'+chunks[2];
  </code></pre>
  
  <p>Now I got the string 07-15-2011 which is in <code>mm-dd-yyyy</code> format, and I can pass it to the <code>Date()</code> constructor to create a <code>Date</code> object. I wish to know if there is any cleaner way to do this.</p>