Date function returning 12-31-1969 | 2009-07-24

Technology Blog » Web Development

If your PHP call of MySQL table returnning 12-31-1969, don't even think you got the SQL correct and table selected,but just there is something wrong with PHP code you wrote. In most case, it is that you echo the table without selecting it in your SQL.

e.g.: date('m-d-Y', $row["last_post"] )

And your SQL is   $search_query = "SELECT a.id, a.poster, a.first_post_id, a.subject, a.num_views, a.num_replies, b.id,  b.topic_id FROM a, b";

You have whole bounch of select query, but look at it, you don't even have something called "a.last_post" or "b.last_post" for this Left Join SQL.This is a very common mistake that one will make. And PHP date() function doesn't return Null or False value really gonna confuse us and assume there is no problem in the SQL.

So if you insert Select last_post, the problem will be fixed immediately.