Hey team, I’d like to know if cron Schedule of a f...
# prefect-community
a
Hey team, I’d like to know if cron Schedule of a flow can be aware of the timezone? The host uses UTC timezone, but I want to have the cron schedule executes based on a specific timezone, for example every 2pm of a local time. Thanks.
c
Hey Alfie - absolutely! Whatever timezone the
start_date
of your individual clocks has will be respected. Configuring this depends on the interface - if you use the higher level schedule interface:
Copy code
import pendulum
from prefect.schedules import CronSchedule

pst_start_date = pendulum.now("US/Pacific")

schedule = CronSchedule(cron_string, start_date=pst_start_date)
If you are using the lower level clocks interface directly, then each clock can be passed its own start date with its own timezone configuration:
Copy code
import pendulum
from prefect.schedules.clocks import CronClock
from prefect.schedules import Schedule

pst_start_date = pendulum.now("US/Pacific")
est_start_date = pendulum.now("US/Eastern")

west_clock = CronClock(cron_string, start_date=pst_start_date)
east_clock = CronClock(cron_string, start_date=est_start_date)

schedule = Schedule(clocks=[east_clock, west_clock])
a
that’s great, will try on it, thanks!