PHP 7天后删除记录?

发布于 2024-10-18 06:54:28 字数 588 浏览 4 评论 0原文

我想从数据库中删除 7 天或更早的记录。我将服务器时间设置为英国时间,但由于某种原因,我在下面编写的代码总是回显帐户已删除 7 天或以上,并且由于某种原因它无法正常工作。在对测试数据库进行测试之前,我决定暂时使用简单的 echo,但正如我所说,它不起作用。

有人有任何建议为什么它不起作用吗?我一定是做错了什么。

<?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';
}

?>

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';
}

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各空 2024-10-25 06:54:28

strtotime(time('1298039664')) 替换为 1298039664

time() 不带任何参数。

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

time() does not take any parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文