title: Cannot get my date of dd/mm/yyyy to format into mm/dd/yyyy
body: <p>I need your help,</p>
  
  <p>I have the first two date formats working with the long date that is returned by the server. However when I call the function dateToMDY(date) to the 3rd div, the date format remains as dd/mm/yyyy. What a pain. What am I doing wrong here? All looks to be in order. Did I miss anything?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;style type="text/css"&gt;
  
  &lt;/style&gt;
  
  &lt;script type="text/javascript"&gt;
  function test() {
  
  var x = "Mon Mar 5 00:00:00 EST 2012"
  
  var y = "05/03/2012"
  
  document.getElementById('divy1').innerHTML = dateToDMY(new Date(x))
  
  document.getElementById('divy2').innerHTML = dateToMDY(new Date(x))
  
  document.getElementById('divy3').innerHTML = dateToMDY(new Date(y))
  
  }
  function dateToDMY(date) {
      var d = date.getDate();
      var m = date.getMonth() + 1;
      var y = date.getFullYear();
      return ''+  (d &lt;= 9 ? '0' + d : d)  +'/'+ (m&lt;=9 ? '0' + m : m) + '/' + y;
  }
  
  function dateToMDY(date) {
      var d = date.getDate();
      var m = date.getMonth() + 1;
      var y = date.getFullYear();
      return ''+ (m&lt;=9 ? '0' + m : m)+'/'+ (d &lt;= 9 ? '0' + d : d)  + '/' + y;
  }
  
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body onload="test()"&gt;
  
  dd/mm/yyyy (DatePicker)
  &lt;div id="divy1"&gt;&lt;/div&gt;
  &lt;br&gt;
  mm/dd/yyyy (SQL)
  &lt;div id="divy2"&gt;&lt;/div&gt;
  &lt;br&gt;
  Default Date String should be converted to mm/dd/yyyy
  &lt;div id="divy3"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>