View Full Version : format the date pulled from MySQL DB.
BigToque
01-20-2005, 05:52 PM
I've got a date field in my DB that stores dates as "yyyy-mm-dd"
When I get the results into PHP, how can I format the date as "Month dd, yyyy"? (ie: in the DB I've got "2005-1-20", I want "January 20, 2005")
Brandoe85
01-20-2005, 05:53 PM
Try Date Format (http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html)
BigToque
01-20-2005, 10:05 PM
DATE_FORMAT() wasn't working for me, but I got it working using date().
Thanks for the help
marek_mar
01-20-2005, 10:16 PM
A good idea would be to store php's unix timestam in a INT(11) field. You could convert it to anything you want with date and add or substract hours (to get the right time in different timezones).
Brandoe85
01-20-2005, 10:17 PM
Wouldn't this work?
SELECT date_format(DateField, '%M %d, %Y') from TableName;
marek_mar
01-20-2005, 10:21 PM
:confused: No Idea. You tested it, right? You are relying on a DB function. If you'd like to change the DB you use it may not have that function (or it may have a different name). This is a rather advanced tip so you don't have to use it.
Brandoe85
01-20-2005, 10:27 PM
Sounds good, thanks for the tip, marek_mar :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.