C# error "String was not recognized as a valid DateTime"
<p>I am trying to save the DateTime.Now in the format "yyyyMMdd"</p>

<p><strong>I have this code</strong></p>

<pre><code>string todaysDate = DateTime.Now.ToString();
</code></pre>

<p>...</p>

<pre><code>U_Date_of_PD_added = GetDateFromString(todaysDate) 
</code></pre>

<p>// U_Date_of_PD_added is a datetime Database field</p>

<p>...</p>

<pre><code>//Method to get date from string
private DateTime GetDateFromString(string dateString)
{
   string format = "yyyyMMdd";
   return DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture);
}
</code></pre>

<p>I keep getting the error "String was not recognized as a valid DateTime." as it tries to parse. What could be wrong?</p>

<p>I do not care if it saves the time, I would prefer 00:00:00.000</p>
