Forum Moderators: coopster

Message Too Old, No Replies

strtotime 30mins ago

         

ahmedtheking

9:32 pm on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How can I use strtotime to return the time 30 mins ago, for example:

date("ymd H:i:s",strtotime("-30 minutes"));

ahmedtheking

9:36 pm on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry ignore that, it's all good.

ericjust

9:39 pm on Apr 12, 2007 (gmt 0)

10+ Year Member



Your example works.

ahmedtheking

9:52 pm on Apr 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep it does! Ok, so now, I'm looking at the best way I can compare data within my MySQL database to see what times are longer than 30 mins ago. Now is the best way to do the checking via php or mysql? And what would be the code? If any?

coopster

1:59 am on Apr 14, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I would use the database engine:
SELECT CURRENT_TIMESTAMP - INTERVAL 30 MINUTE;

ahmedtheking

12:52 pm on Apr 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How would I script that? SELECT * FROM table WHERE userstimestamp <= CURRENT_TIMESTAMP?

ahmedtheking

12:56 pm on Apr 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok this worked: select * from LoggedIn where lastupdate <= (CURRENT_TIMESTAMP - INTERVAL 21 MINUTE);

Thanks for the help!