Advertisement:

(MySql) Compare current date with post date

Aloittaja PS4DEV, maaliskuu 23, 2014, 05:42:41 IP

« edellinen - seuraava »

PS4DEV

Hello,

I have some problems with comparing two timestamps in mysql.

I want so compare the current time with the timestamps of my posts, and take all the posts that have been created the last day (24 hours).

Here is what I tried so far:

WHERE  UNIX_TIMESTAMP(CURDATE()) - UNIX_TIMESTAMP(m.poster_time) <= 60*60*24

but I don´t get it working.

Can someone help, please ?


vbgamer45

I would do something like
UNIX_TIMESTAMP(m.poster_time) >=  (UNIX_TIMESTAMP(CURDATE()) - 60*60*24)
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

PS4DEV

Thank you that helped.

I did myself another mistake,
you need to use NOW() and not CURDATE()

Here is the working code:
WHERE m.poster_time >=  (UNIX_TIMESTAMP(NOW()) - 60*60*24)

Advertisement: