php check datetime from url
<p>Date and time from URL shall be in format YYYY-MM-DD-HH-II-SS. I want to check it correctness and insert into database in column of mysql timestamp format.</p>

<p>1) With <code>$timestamp = $this-&gt;input-&gt;get('time_from')</code> I receive it from url.</p>

<p>2) Before insertion in database I try to print it.</p>

<pre><code> if (! empty($timestamp)) {
        $timestamp = date_create_from_format('Y-m-d-H-i-s', $timestamp);
        if (! $timestamp)
            echo date_format($timestamp, 'Y-m-d H:i:s');
     }
</code></pre>

<p>3) I obtain that year could be before 1970, for example 1950-01-01-10-32-01 is correct by this checking. But it is impossible to insert such date in mysql column.
4) I obtain that 2012-02-31-10-00-00 is transformed automatically in 2012-03-02 10:00:00.</p>

<p>The questions are: how to avoid these confusing automatic transformations? What is the best way to provide such checking?</p>
