On 01/14/2010 11:01 AM, John Taylor-Johnston 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
Something like: <?php date_default_timezone_set('Europe/Copenhagen'); $somedate = '2007-02-13'; echo date("F", strtotime($somedate)); echo "\n"; echo date("Y", strtotime($somedate)); Output: [michael@archie ~]$ php a.php February 2007 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php