<p>Is there a way to check to see if a date/time is valid you would think these would be easy to check:</p>

<pre><code>$date = '0000-00-00';
$time = '00:00:00';
$dateTime = $date . ' ' . $time;

if(strtotime($dateTime)) {
    // why is this valid?
}
</code></pre>

<p>what really gets me is this:</p>

<pre><code>echo date('Y-m-d', strtotime($date)); 
</code></pre>

<p>results in: "1999-11-30",</p>

<p>huh? i went from 0000-00-00 to 1999-11-30 ???</p>

<p>I know i could do comparison to see if the date is either of those values is equal to the date i have but it isn't a very robust way to check. Is there a good way to check to see if i have a valid date? Anyone have a good function to check this?</p>

<p>Edit:
People are asking what i'm running:
Running PHP 5.2.5 (cli) (built: Jul 23 2008 11:32:27) on Linux localhost 2.6.18-53.1.14.el5 #1 SMP Wed Mar 5 11:36:49 EST 2008 i686 i686 i386 GNU/Linux</p>

echo date('Y-m-d', strtotime($date));
results in: "1999-11-30"
The result of
```
strtotime
```
is 943920000 - this is the number of seconds, roughly, between the
Unix epoch
(base from which time is measured) to 1999-11-30.
There is a
documented
mysql bug
on
```
mktime(), localtime(), strtotime()
```
all returning this odd value when you try a pre-epoch time (including "0000-00-00 00:00:00"). There's some debate on the linked thread as to whether this is actually a bug:
Since the time stamp is started from 1970, I don't think it supposed to
  work in anyways.
Below is a function that I use for converting dateTimes such as the above to a timestamp for comparisons, etc, which may be of some use to you, for dates beyond "0000-00-00 00:00:00"
```
```
/**
 * Converts strings of the format "YYYY-MM-DD HH:MM:SS" into php dates
 */
function convert_date_string($date_string)
{
    list($date, $time) = explode(" ", $date_string);
    list($hours, $minutes, $seconds) = explode(":", $time);
    list($year, $month, $day) = explode("-", $date);
    return mktime($hours, $minutes, $seconds, $month, $day, $year);
}
```
```