hello, i have variable $foo that is pulling a date from MySQL that has the date stored in this format: 0000-00-00 00:00:00 (Year-Month-Day Hour:Minute:Second) how can I format the date stored in $foo?
I dunno if that will happen without a custom function off hand. The date should be stored as a Unix timestamp and then date() used to format it. Any way, break it out and use mktime to pull it off. http://us3.php.net/manual/en/function.mktime.php
Damn, you are fast. hehe Try to break it out and use mktime to pull it off. http://us3.php.net/manual/en/function.mktime.php
Break your date string out with a few substr calls and feed it to mktime. http://us2.php.net/manual/en/function.substr.php Store each of Year-Month-Day Hour:Minute:Second in a different varaible and pop out the date as you wish.
You can also get the mysql date fields in unix timestamp format with UNIX_TIMESTAMP like this: Then format it as you need with date().
Here's what you need to do, its pretty simple: $NewDate = date("String format you want", strtotime($foo)); PHP: or you could do what wmtips mentioned by storing the UNIX timestamp in $foo and then do this: $NewDate = date("String format you want", $foo); PHP: or you could even just do it all in the query using the MySQL Function DATE_FORMAT