View Full Version : Formatting Dates

08-08-2008, 02:30 AM
I'm trying to format my date in a database table. Is there a way to do it in the mysqladmin or how do you have to do? It appears right now like 2008-08-08 but I want it to appear like July 8, 2008

I have it in my php code as:

<p><b>Date Won</b><br>'.$row['datewon'].'

08-08-2008, 02:46 AM
Where you fetch datewon from the query, just modify it to

SELECT field1, field2, etc, DATE_FORMAT('datewon', '&#37;M %e, %Y') WHERE whatever='who';

08-08-2008, 02:52 AM
After I put this in and tried to run it. It said that there was an unexpected T_String

$query = 'SELECT *, DATE_FORMAT('datewon', '&#37;M %e, %Y') FROM titles';

08-08-2008, 02:53 AM
Change the 1st and last single quotes to double ones, eg " instead of '

$query = "SELECT *, DATE_FORMAT('datewon', '&#37;M %e, %Y') FROM titles";

The single quotes in the date_format() were breaking the line

08-08-2008, 02:56 AM
I got it to show atleast but it isn't formatting it correctly still.

08-08-2008, 02:59 AM
Ok, try this maybe

$query = "SELECT *, DATE_FORMAT('datewon', '&#37;M %e, %Y') AS dateofwin FROM titles";

Then call $row['datewon'] as $row['dateofwin'] instead

I'm doing this completely off memory as haven't done this for about 5 years

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum