title: C# Convert String to Date Time Whereas string has AM : PM formate
body: <p>I have string time. lets say '06:35 PM'. I want to convert the string to DateTime.
  The date must be current time(the day as they input the time).</p>
  
  <p>I did </p>
  
  <pre><code>string times = endTime;
  DateTime dt;
  (DateTime.TryParseExact(times, "YYYY-MM-dd HH:mm tt", CultureInfo.InvariantCulture,DateTimeStyles.None, out dt))
  </code></pre>
  
  <p>But it didn't works. it make a null value. because when I try to put the result on label, the label did not show anything. and also I have been try </p>
  
  <pre><code>var date = DateTime.Parse("06:45 AM");
  Console.WriteLine(date);
  </code></pre>
  
  <p>But it didn't works too and it makes an error.</p>
  
  <blockquote>
    <p>ERROR System.Data.SqlClient.SqlException (0x80131904): The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated. "</p>
  </blockquote>
  
  <p>How do I convert it ?</p>