Add timezone option to ScheduleConfig for job scheduling #16141
VlatkoGoljevacki
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
|
This is a very good suggestion! I also had this issue and sometimes wanted cron to be in a local timezone. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
All cron expressions in
ScheduleConfigare evaluated bycronerusing the server's local timezone. Most cloud environments (AWS ECS/Fargate, GCP Cloud Run, Railway, etc.) default to UTC. Thismeans a schedule like
{ cron: "0 9 * * *" }intended for "9:00 AM local time" actually fires at 9:00 UTC — which is offset by 1–2 hours depending on DST for European timezones, and up to 12+hours for others.
This causes real bugs: in our case, daily notification jobs meant for 9:00 AM Europe/Zagreb fired at 10:00 CET (winter) and 11:00 CEST (summer). The shift on DST boundaries is especially
confusing because the behavior changes without any code change.
The underlying library (
croner9.1.0) already supports timezone-aware evaluation via{ timezone: 'Europe/Zagreb' }, but Payload doesn't expose this option.Proposed solution
Two small changes, fully backward-compatible:
1. Add
timezonetoScheduleConfigpackages/payload/src/queues/config/types/index.ts:packages/payload/src/queues/operations/handleSchedules/index.ts, line 144:
Why this matters
Current workaround
We use the beforeSchedule hook to recompute waitUntil with a timezone-aware croner instance, calling defaultBeforeSchedule first to preserve the duplicate-job prevention logic:
This works but requires every scheduled task to use the wrapper, and the lastScheduledRun lookup duplicates internal logic from checkQueueableTimeConstraints. The native two-line fix would
eliminate this entirely.
Beta Was this translation helpful? Give feedback.
All reactions