title: Conversion from String to DateTime in C#
body: <p>I want to convert a String to Datetime. I'm getting an error <code>This is not a valid datetime</code>.  </p>
  
  <p>The string I want to convert and code are as follows.</p>
  
  <pre><code>string date1 = "9/13/2012 5:26:06 PM";
  TimePart = DateTime.ParseExact(date1, "M/d/yyyy HH:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
  </code></pre>