WP cron daily issue
-
In wordpress, a day is defined as having 24 hours:
wp-includes/default-constants.php: define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
but that doesn’t take summer/winter time into account of course.
While it is being stated above the definition that these values are approximate and are provided for convenience, the DAY_IN_SECONDS is being used in the “daily” cron definition. This means if you plan something to happen at midnight (say membership status recalc, half of the year it will happen one hour later/earlier (depending on the day you planned it initially).
So, in order to be sure something happens “as soon as the new day starts”, you need to plan it at 01:00 at the earliest …
Since the fixed wp schedules are in fact “fixed”, why not have them calculate “daily” as the DateTime function “+1 day”? The same goes for weekly, monthly, yearly.I know WP cron doesn’t run exactly the moment you want it (unless you use system cron), if running something “daily” at around midnight and it causes it to be ran at 23:00 instead, you might be giving people an extra free day entrance (again for memberships).
- The topic ‘WP cron daily issue’ is closed to new replies.