Jump to content

update record where timestamp is 10 days old


petroz

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.