title: Convert any DateTime string format to US short date "MM-dd-yyyy"
body: <p>I am trying here to write a generalized code to convert any provided valid <code>date</code> / <code>datetime</code> formatto <strong>US short date format</strong>.</p>
  
  <p>Below is the code I am trying:</p>
  
  <pre><code>public static string ConvertToUSDateFormat(string dateString)
  {
        string[] formats = {"dd/MM/yyyy", "dd-MMM-yyyy", "yyyy-MM-dd","yyyy-MM-dd hh:mm:tt", "dd-MM-yyyy hh:mm:tt", "M/d/yyyy", "dd MMM yyyy","dd/MM/yyyy hh:mm:tt", "MM-dd-yyyy hh:mm:tt", "dd-MM-yyyy h:mm:tt"};
        string convertedDate = DateTime.ParseExact(dateString, formats, CultureInfo.InvariantCulture, DateTimeStyles.None).ToString("MM/dd/yyyy");
        return convertedDate;
  }
  </code></pre>
  
  <p>The <strong>input</strong> I am providing to this method is <strong><code>19-01-2018 10:55:52</code></strong>.</p>
  
  <p>But this code is throwing an error: <strong>String was not recognized as a valid DateTime.</strong></p>