Being experienced in PHP, I lack in the area of comparing two dates in database.
I have two values stored in my database. Which are simply just unix time stamps.
Value 1: post_time
Value 2: expire_time
The expire time is just 7 days after the posted time. I simply need to get all posts that haven't "expired".
For the time being I've been using: if(($post['post_time']) >= time() - (60*60*24*7)), which works fine. But I'd much rather find a solution right in the query to get the results. Rather than pull all results and then filter them later.
Here is my query:
SELECT id, uid, title, description,
price, image, tags, post_type,
category, post_time, expire_time
FROM posts
ORDER BY RAND() LIMIT 8
Your help is appreciated.
WHERE post_time >= UNIX_TIMESTAMP(NOW()) - (60*60*24*7)