Re: parse date field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use strttotime() function. This will work as intended.

$mydata->birthday = strtotime("2007-02-13");
#What month is it?
echo date("F", $mydata->birthday);
#What year is it?
echo date("Y", $mydata->birthday);

-
--
Vikash Kumar
http://vika.sh


On Thu, Jan 14, 2010 at 3:31 PM, John Taylor-Johnston <
John.Taylor-Johnston@xxxxxxxxxxxxxxxxxxxxx> wrote:

> How do I parse a date field from mysql?
>
> I was hoping this would work:
>
> $mydata->birthday = "2007-02-13";
> #What month is it?
> echo date("F", $mydata->birthday);
> #What year is it?
> echo date("Y", $mydata->birthday);
>
> What am I missing? All I get is December 1969. Hmmm?
>
> I am looking at the manual:
> http://ca.php.net/manual/en/function.date.php
> http://ca.php.net/manual/en/function.mktime.php
> http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux