doucu5836 2011-02-19 02:14
浏览 39
已采纳

7天后PHP删除记录?

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

?>
  • 写回答

1条回答 默认 最新

  • dongshi8038 2011-02-19 02:20
    关注

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

    time() does not take any parameters.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频