문제

I basically have a simple calendar I set up. As of now, it shows "future" events. And then the event expires that day... I would love to find a WHERE statement that I can use to have that "event" stay up for 1 day past the "post_date"

(so if I post it as Nov. 15th,) The event would show: Name of event - Nov. 15th

And It would stay active until +1 day from post_date? (Nov. 16th would be the expire date)

Here is what I have so far:

WHERE DATE(FROM_UNIXTIME(`date`)) >= DATE(NOW())

Thanks in advance...

도움이 되었습니까?

해결책

WHERE post_date > DATE(NOW())-INTERVAL 1 DAY

and if you really want to keep your post_dates in UNIX timestamps:

WHERE FROM_UNIXTIME(post_date) > DATE(NOW())-INTERVAL 1 DAY

다른 팁

Change your where statement to:

WHERE DATE(FROM_UNIXTIME(`date`)) + INTERVAL 1 DAY >= CURDATE();

Also a good idea to to use real SQL dates instead of UNIX timestamps. There are functions to do calculations on them.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top