I have news items that when created adds the time of creation date/time in unix timestamp format into the database. If i wanted to order by most recent first would i use ASC or DESC in my mysql query?
EDIT:
Thanks everyone for replying. I understand now. I will make Sarfraz answer the accepted solution as he was first to reply but thanks to everyone else to :) . Have to wait 11 minutes before i can accept it as a solution开发者_StackOverflow中文版.
DESC - timestamps are "higher = newer" number. So sorting by DESC(ending) will put the highest (newest) entries first.
You should perform a SQL Query like below
SELECT * FROM News ORDER BY date DESC
If i wanted to order by most recent first would i use ASC or DESC in my mysql query?
You would order by DESC
for the most recent info or higher date.
Unix timestamp is number of seconds since the epoch (Dec. 1969). So, newer posts have a higher number, thus, sort DESC
.
DESC
will put the largest first, which would be the most recent.
精彩评论