Trigger a cron every 24h GMT -8

Almost,

WP Cron jobs do not run at specific times, they are approximate, and all timestamps should be UTC, as WordPress always deals in UTC timestamps. If you want midnight PST, you’ll want to specify 8PM UTC.

Also for example, your above code suggests midnight PST, but it may not run at midnight PST. If nobody visits the site at the specified time, and there’s 4 hours before someone arrives, then the cron job will occur at 4am.

If you’re wanting accurate cron jobs that are not approximate, you will need to setup a server cron job to call the wp cron URL at fixed intervals.

I would also choose a more specific name than ‘cron_hook’ to prevent clashes and issues in the future

You can test this easily by just figuring out what time midnight PST is in UTC, aka 8AM, does your cornjob fire at 8AM UTC?

Leave a Comment