+
95
-

回答

将执行的时间时分秒转换是时间戳,再跟当前时间戳运算获取间隔相差的秒数,然后再调用swoole timer实现定时执行,代码如下:

<?php
$exetime = strtotime('2022-10-13 18:26:33');//设定执行的具体时间,日期和时分秒
$intval = $exetime-time();//获取间隔也是秒
Swoole\Timer::after($intval, function() {
echo "executed";
});


网友回复

我知道答案,我要回答