Add 0's to dates where it is missing in c#?
<p>I have a string with a value in the format of</p>

<pre><code>dd/mm/yyyy
</code></pre>

<p>Now I want to compare that to another string and check if they are equal, the other string can have the value of</p>

<pre><code>dd/mm/yyyy
</code></pre>

<p>or sometimes when the day is between 1 and 9:</p>

<pre><code>d/mm/yyyy
</code></pre>

<p>Sometimes when the month is between 1 and 9:</p>

<pre><code>dd/m/yyyy
</code></pre>

<p>So there are a couple of instances where the string isn't equal but the actual date is.
First I only saw that in some cases when the day is between 1-9 it doesn't start with a zero so I did:</p>

<pre><code>createdDate = dateField.value.ToString().Substring(0, 10);
createdDate = createdDate.Trim();
if (createdDate.Length == 9)
    createdDate = "0" + createdDate;
</code></pre>

<p>but then I saw that it can be the same for month so there must be a better way to check this?</p>
