Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PhP] date format help request

3 views
Skip to first unread message

Moose

unread,
May 25, 2008, 2:40:49 AM5/25/08
to
I have a .PhP web page that gets its results from a query like
$result = mysql_query("SELECT * FROM myTable Order by DueDate",$db);

The result includes a field with a date, which gets returned as
"2008-05-25".

What would be required to have the query return a date with the format
like "05.25.2008".

I have to figure this has to have a simple solution, but I don't know
whether to start with the MySQL database settings or by using PhP.

Thanks,

RBenson

unread,
May 26, 2008, 1:02:45 AM5/26/08
to
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format

$result = mysql_query("SELECT field1, field2,
DATE_FORMAT('DueDate','%c.%e.%Y') FROM myTable Order by DueDate",$db);

fwd...@gmail.com

unread,
May 26, 2008, 8:34:30 AM5/26/08
to
Hi Moose,


You can use the date() and strtotime() function to convert your
result;

You can try like this:
echo date( "m-d-Y", strtotime("2008-05-25") );


OUTPUT:
05-25-2008


Regards,

Fahad Khan

0 new messages