Page 1 of 1
Showing date as different format?
Posted: Sat Jun 06, 2009 6:09 pm
by tomsace
Hello,
When a user registeres to my website it saves the date they joined in the format yyyy-mm-dd
How can I display the date they joined as dd mm yyyy (22nd march 2009 for example)
Thanks.
Re: Showing date as different format?
Posted: Sat Jun 06, 2009 6:20 pm
by requinix
If you stored the date in the database as YYYY-MM-DD then use MySQL's
DATE_FORMAT function.
Code: Select all
SELECT ...DATE_FORMAT(field, "%D %M %Y")...
Re: Showing date as different format?
Posted: Sat Jun 06, 2009 6:29 pm
by tomsace
thanks! but how do I change it from say 1 may 2009 to 1st may 2009?
Re: Showing date as different format?
Posted: Sat Jun 06, 2009 6:54 pm
by kalebaustin
DATE_FORMAT(field, "%D %M %Y") will return (for today) 6th June 2009
the %D = Day of the month with English suffix (0th, 1st, 2nd, 3rd, …)
Source:
http://dev.mysql.com/doc/refman/5.1/en/ ... ate-format