check the format of a date in PHP
<p>I have a date input that requires the user to enter the date in the following format: DD-MM-YYYY - It is then converted to YYYY-MM-DD</p>

<p>I want to perform a check to see whether they are entering the correct format. i.e. if anything else is entered other than DD-MM-YYYY then it should produce an error message</p>

<p>Im currently using the following</p>

<pre><code>                    list($y, $m, $d) = explode('-', $date);

                    if(checkdate($m, $d, $y)){

                    }else{
                        die("The date was in the wrong format");
                    }
</code></pre>

<p>I have tried putting the code that follows this inside the if statement, aswell as not including the else at all - but it does not work. Any suggestions on what i can try? Thankyou </p>
