Does 'asc' sorting order sorts my createdAt timestamps from the oldest to the latest or viceversa?
Hello everyone,
I want to sort my MySQL records by the
createdAt
timestamp, so if I specify the orderBy
to be asc
, then will it sort the records from the oldest to the latest or vice-versa?
Thanks in advance?2 Replies
You can think of timestamps as numbers that are converted to be easier for us to read. As we move forward in time, the timestamp grows larger.
So, more recent timestamps are larger than older timestamps. That means that ASC will show oldest first (smallest -> largest, oldest -> newest) DESC will show newest first (largest -> smallest, newest -> oldest)
Thank you, really appreciate this clarification