title: convert string to datetime format and date only in c#
body: <p>How can I convert the string to datetime. I have following string:</p>
  
  <pre><code>08/19/2012 04:33:37 PM
  </code></pre>
  
  <p>I want to convert above string to following format date:</p>
  
  <pre><code>MM-dd-yyyy
  </code></pre>
  
  <p>and</p>
  
  <pre><code>dd/MM/yyyy HH:mm:ss
  </code></pre>
  
  <p>I have been trying to convert using different technique and using following:</p>
  
  <pre><code>DateTime firstdate = DateTime.Parse(startdatestring);
  </code></pre>
  
  <p>It shows following error</p>
  
  <blockquote>
    <p><em>String was not recognized as a valid DateTime.</em></p>
  </blockquote>
  
  <p>I have search for it and couldn't get exact solution and also try using different format for datetime. Please how can I convert above string to above date format</p>