-4

我正在尝试每天早上 7 点运行一个 php 进程。为此,我为 time 维护一个 db 列,我应该在其中更新第二天的相应微时间。我能够得到第二天的时间,date('Y-m-d', strtotime('+1 day'));但我想要明天早上 7 点对应的时间。

任何人都可以帮助我如何获得第二天早上 7 点的相应时间,以便我可以根据 db 列进行更新。

4

3 回答 3

5

把它放进去strtotime()

$unix = strtotime('tomorrow 7am');//unix timestamp

不知道为什么你需要微时间?

于 2013-08-19T14:57:52.197 回答
0

使用mktime

mktime($hour = 7, $minute = 0, $second = 0, $month = date('n'), $day = date('j') + 1))

这将为您提供时间戳(以秒为单位)。如果你真的需要微时间,乘以 1000

于 2013-08-19T14:58:15.920 回答
0

通过使用 *nix 机器中的 Cron 选项卡,可以使用另一种简单的方法来启动计划为每 n 分钟/小时运行一次的活动。

* 7 * * * /path/to/wget /path/to/php

这将在每天 @ 07:00 时启动您的 PHP 文件。

有关 crontab 的更多信息

于 2013-08-19T15:05:44.297 回答