这个代码对我有用,我相信它更接近原始问题。您希望在希望执行时获取UNIX时区。一旦cron执行并从WP中删除,它就会在指定的时间重新创建自己。
在下面的示例中,我让它在每天早上6点为AEST(GMT+10)工作。所以我把它安排在每天格林尼治时间20:00。
if (!wp_next_scheduled(\'cron_name\')) {
$time = strtotime(\'today\'); //returns today midnight
$time = $time + 72000; //add an offset for the time of day you want, keeping in mind this is in GMT.
wp_schedule_event($time, \'daily\', \'cron_name\');
}