0

我正在尝试运行基于时间范围触发的 wp_cron 事件。但是我可以设置一个小于某个时间段但不在一个范围内的间隔。场景是,如果$wp_cron_start设置为中午之前的时间,并且如果$wp_cron_start大于当前时间,则可以在当天触发,如果不满足这些条件,则将 wp_cron 设置为第二天运行。问题的第一个条件不起作用。说为情景$wp_cron_start = "08:00"

$wp_cron_start = "08:00";
if ($wp_cron_start < date('12:00') && $wp_cron_start > date("H:i")) {
            if(!wp_next_scheduled('cron_hook')) {
                wp_schedule_event(strtotime($wp_cron_start), 'daily', 'cron_hook');
            }
        } else {
            $cron_date_start = date('D H:i:s', strtotime('+1 Weekday' . $this->options['bbna_morning_button_end_time']));
            wp_schedule_event(strtotime($cron_date_start), 'daily', 'cron_hook');
        }

这只会设置第二天的 wp_cron。而且它仍然没有开火。

4

0 回答 0