Formatting Date
Posted: Mon Jul 07, 2008 9:23 pm
Hi, im a newbie in PHP. How can i format a date with a value of '01/31/2008' to become '2008-01-31'?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Where is the '01/31/2008' coming from? A MySQL query? A user form? It makes a difference, because if it's coming from a query, that's just the default format, it's actually stored as a huge number, so you can format it right in the query. If it's coming from a user input, as text, you will have to parse the string to get the values for year, month and day, then use mktime() to generate the actual date (huge number), then use date() to format it the way you want it. Click on those blue links to read how to do it.bulsecoip wrote:Hi, im a newbie in PHP. How can i format a date with a value of '01/31/2008' to become '2008-01-31'?