I have a site where I want to show articles that have been posted the last 24 hours. I thought it would be easy but I cannot understand what I am doing wrong.
Lets start from the begining, in mysql I have this table:
id | editor | article | date
-----------------------------
128| 8 | .... | 2013-03-20 01:01:26
129| 8 | .... | 2013-03-20 01:03:24
date field is TIMESTAMP.
Now in php I have this code:
$date = date('Y-m-d H:i:s', strtotime('-1 day')); //24 hours ago
$articles = mysql_query("SELECT * FROM articles WHERE editor=8 AND 'date' > '".$date."' ORDER BY id DESC");
If I run this code now that my local timestamp is "2013-03-21 15:20:07" (more than 24 hours than the articles timestamp) I still get the articles, although I shouldn’t because 2013-03-20 01:01:26 (article 128 timestamp) < 2013-03-20 15:20:07 (now - 1 day). I also run the code through phpmyadmin and the results where the same.
I cannot see what I am doing wrong, I tried experimenting with other tables of my database that have date fields and I still couldn't get it to work.
Thanks a lot.