Jump to content
  • Advertisement
Sign in to follow this  
bmorency

php and mysql. retrieving records older than 10 minutes

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am kinda new to mysql and I am writing a php function to retrieve records that are older than 10 minutes old. I have been spending a lot of time on this function and nothing is working for me. I have a column that is a DATETIME type called 'datetime' that has the date and time the record was entered into the DB. Here is the query i am using. $query = "SELECT * FROM ".usertable." WHERE DATE_SUB(CURDATE(),INTERVAL 10 MINUTE) > datetime"; i am not sure why nothing is getting deleted. if I switch the greater than sign to a less than sign it will clear the table even though some records can be less than 10 minutes old. Does anyone have any idea what the problem could be? thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
sorry. i forgot to mention that the records that should be getting returned using this select statement are being deleted by a delete function that I have made. they are not being deleted by this select statement.

Share this post


Link to post
Share on other sites
Try storing date & time as a BIGINT. I find this datatype much easier to work with especially when calculating differences between 2 timestamps.

In PHP..
$time = time(); // get time as long int

// covert to string eg: '26/5/2005 5:26 pm'
$date_str = date("d/m/y g.i a", $time);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!