petroz Posted September 17, 2009 Share Posted September 17, 2009 Hi Guys, I have a cron job running that is supposed to update all records where the 'time' field is older that ten days. It seems to updating the entries within just a few hours of the timestamp instead of ten days. Please help!! <?php include 'db.php'; $time = date("YmdHis"); $requests = "UPDATE requests SET status=4 WHERE time <= ($time-864000)"; $requestsresult = mysql_query($requests) or die("Invalid remove query: " . mysql_error()); ?> Thanks, P Quote Link to comment Share on other sites More sharing options...
DJTim666 Posted September 17, 2009 Share Posted September 17, 2009 Your $time variable should be time(). That'll fix your problem. Quote Link to comment Share on other sites More sharing options...
petroz Posted September 17, 2009 Author Share Posted September 17, 2009 Thanks DJTim, Will that be the case even if I am storing the timestamp in mysql like so "2009-09-16 23:22:06"? Thanks, P Quote Link to comment Share on other sites More sharing options...
DJTim666 Posted September 17, 2009 Share Posted September 17, 2009 No, you'll have to change the way you're storing the time in your database if you want to run the query like that. mktime() should be able to help you convert. Edit: I always use a UNIX timestamp to insert dates into the database. It's much more flexible than having an actual date stamp. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.