PHPLOVER
PHPLOVER

Reputation: 7257

PHP Delete Record after 7 Days?

I want to delete records from a database when they are 7 days or older. I have my server time set to UK time but for some reason the code I wrote below always echo's Account Deleted as 7 or more days old and for some reason it's not working. Before I test on my test database I decided to use a simple echo for now, but as I say it won't work.

Anyone have any suggestions why it's not working? I must be doing something wrong.

<?php

// Get Current Time
$current_time = time();

/* The time i used below (unix) for testing is 
18-02-2011 14:34:24 (yesterdays date/time) */
$account_delete = strtotime(time('1298039664'));

if ($current_time - $account_delete >= (7*24*60*60)){
echo 'Account Deleted as 7 or more days old';
} else {
  echo 'Account Not Deleted as less than 7 days old';
}

?>

Upvotes: 1

Views: 1371

Answers (1)

user479911
user479911

Reputation:

Replace strtotime(time('1298039664')) with 1298039664?

time() does not take any parameters.

Upvotes: 6

Related Questions