Re: How to select rows where timestamp is in last 10 mins

From: Date: Fri, 23 Aug 2002 19:59:58 +0000
Subject: Re: How to select rows where timestamp is in last 10 mins
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-113843@lists.php.net to get a copy of this message
> Hi. > I need to show whos been online in the last 10 mins on my site, does anyone > know how i would do this? - im talking about just the mysql query and any > php functions needed, and i dont want you to say, use function BLAH_BLAH() - > coz i'm uneducated with where i should put them in the query. Not meaning to > be bitchy. 10 minutes is equal to 600 seconds, UNIX timestamps are measured in seconds from 1970 so seconds is what you're going to use in the query. Now this is logic - how do you know which stuff that's less than 10 minutes old? Just use the current timestamp, fetchted by either time() or UNIX_TIMESTAMP() (the later is a mysql function) and subtract 600, then all rows you want to select has to be bigger than the number that you get. For example: SELECT * FROM table WHERE timeColumn > (UNIX_TIMESTAMP()-600) If you don't have a script and don't feel like creating one, the link below is a working function for measuring the number of people online on your site: http://www.phpcoded.com/?DO=viewCode&ID=27 Hope this helps some ;-) -Jome

« previous php.general (#113843) next »