Im trying to convert a timestamp formt in my mysql to date and order by this date.
$query = mysql_query("SELECT *,DATE_FORMAT(banfrom ,'%d/%c/%Y') as time FROM ab_list ORDER BY time DESC LIMIT 0,50");
Its not showing the date when I try to do like this:
while($info = mysql_fetch_array($query))
{
echo $info['time'];
}
How can I do for showing the date in the echo and oder by this date??
Thanks guyss
You need to use FROM_UNIXTIME()
to convert timestamp into date first before using DATE_FORMAT
which converts date into string.
DATE_FORMAT(FROM_UNIXTIME(banfrom), '%d/%c/%Y') AS Time
and when you want to order your record, just directly sort the timestamp column,
ORDER BY banfrom DESC