Date_format - php

When I try to format the date of the datetime field in my mysql db and the result is echos, like this:

echo $result["date"];

but still he says, for example, 2012-01-03 10:27:53
my script looks like this:

DATE_FORMAT(date, '%a, %b, &Y')

and he should say 01, 03, 2012 (or something like that)
is the wrong “type” of the echo code that I use, I am new to the whole date_format task, so I really don't know if I will do it right.
entire request:

SELECT id, subject, DATE_FORMAT(date, '%a, %b, %Y') FROM articles ORDER BY id DESC
+5
source share
1 answer

No, you select the original column value date, not the value from DATE_FORMAT().

You need to add an alias that in your SQL query:

DATE_FORMAT(date, '%a, %b, &Y') as formatted_date

And then take it in PHP with

echo $row['formatted_date'];
+5
source

All Articles