douqiaotong8682 2012-02-16 05:21
浏览 149
已采纳

如何在php中的函数上设置24小时的时间延迟?

I have a web application written in php5.

The application allows users to register and I would like to delay when the various details such as password and links will be sent out. I would like the email containing this information to go 24h after a user has resisted.

How can I to execute the function that will send the email after 24 hours has passed?

  • 写回答

2条回答 默认 最新

  • douye2488 2012-02-17 03:29
    关注

    It would depend on how accurate '24' hours needs to be, but something like the following approach should work.

    Create a table to hold user registrations, or adapt an existing table to hold a registrationTime column. Make this column nullable DATETIME you will use it to hold the HH:MM of the users registration. The new (or modified) table should also have the data relevant for the emails, or a common identifier for users, allowing the correct data to be selected.

    Finally, you would set up a cron job to query the data base every x mins and select the users who registered within y mins of 24hours. Where x is how often you want the job to run and y would be some degree of tolerance for how close to 24:00 hours had elapsed.

    For any results you would construct and send the emails. Finally you would set some a flag to show that user had been dealt with - a good way would be setting the registrationTime to null for all users who have had the email sent.

    Here are a few links to help you out:

    Compare time in SQL Server How can I compare time in SQL Server?

    Introducing Cron http://www.sitepoint.com/introducing-cron/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器