Re: strtotime
| From: | Adam Richardson | Date: | Thu, 14 Jan 2010 18:25:48 +0000 |
| Subject: | Re: strtotime | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301109@lists.php.net to get a copy of this message | ||
When you set the date to "0000-00-00", you start the following sequence:
1. strtotime returns false, because "0000-00-00" isn't a date it can
parse into a timestamp.
2. date returns 1969, because it's not passed a valid timestamp and it
works from December 31, 1969 for any invalid date.
On Thu, Jan 14, 2010 at 1:14 PM, John Taylor-Johnston <
John.Taylor-Johnston@cegepsherbrooke.qc.ca> wrote:
> Hello,
>
> In a mysql date() field, I set the default to "0000-00-00".
>
> Therefore, $mydata->birthday = "0000-00-00";
>
> But when I run this next line, $then = 1969.
>
> $then=date("Y", strtotime($mydata->birthday));
>
> Why 1969, and not 0 or nothing?
>
> If I echo strtotime("0000-00-00");
>
> Nothing appears. So $then should be nothing?
>
> What is wrong with my logic?
>
> Thanks,
> John
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com