I don’t know if this is a bug with MySQL or my fault, but it is really starting to get on my nerves.
To get the answers of a user, I use this query (which also makes sure the question is not deleted or hidden):
SELECT *
FROM answers a
JOIN questions q
ON a.questionid = q.qid
WHERE a.userid = <uid> -- query parameter
AND a.deleted = 0
AND q.hidden = 0
AND q.deleted = 0
ORDER BY a.created DESC
The problem is that all of the answers are in order by the timestamp of the time that they were created, except for three of them. In this screenshot of the answers on my profile, take a look at the dates of answers on the questions that say "This question has an issue with the ordering…":

I really do not know what is happening. As you can see the MySQL query has ORDER BY a.created DESC.
What have I tried?
Well, I have tried many things, like echoing out the Unix Timestamp stored in the DB and they’re all correct.
Another thing I tried is calling strtotime() on the timestamps, but that only gave me more issues: the first one was oddly turned into a huge negative number and displayed Aug 3, 1717 but the others were made blank and therefore said Dec 31, 1969.
Edit
It looks like a couple of other of rows are mixed up as well.
Solution
I discovered that both the questions table and the answers table have a created column. I fixed this by doing SELECT *, a.created as ans_created, q.created as q_created and it now works. Thank you to everyone that helped.
I am just going to answer my own question since I figured out what the problem is.
I discovered that both the questions table and the answers table have a
createdcolumn.The problem was that I was ordering by
a.createdin the query but since in the PHP I displayed the date with$row['created']it was ordering correctly but displaying an incorrect date/time.I fixed this by doing…
And then in my PHP I just do
$row['ans_created'].Thank you to everyone that helped in the comments and the other answer. 🙂