Validating user date entry
<p>Hi everyone I have a form that accepts user date entry in the form</p>

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

<p>and converts it to US date in the form</p>

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

<p>How can I return an error if the user does not type in the date in the correct format initially? e.g. <strong>12/2012</strong></p>

<p>This is the code I have so far.</p>

<pre><code>// collect values from a form sent with method=get

$uk_date = $_GET["date"];

// convert between date formats

$parts = explode("/", $uk_date, 3);
$us_date = $parts[2] . "-" . $parts[1] . "-" . $parts[0];
echo $us_date.'&lt;br&gt;';
</code></pre>

<p>Thanks in advance!</p>

<p>I am using PHP btw.</p>
