<@ULVA73B9P> how to specify timezone when deployin...
# ask-marvin
p
@Marvin how to specify timezone when deploying a deployment from python with a cron?
m
thought for 35.4 seconds
Based on the research and signature verification, here's how to specify a timezone when creating a deployment with a cron schedule in Prefect 3.x:
Copy code
python
from prefect import flow
from prefect.schedules import Cron

@flow
def my_flow():
    print("Running flow!")

# Create deployment with timezone-aware cron
deployment = my_flow.to_deployment(
    name="my-scheduled-deployment",
    schedule=Cron(
        cron="0 9 * * *",  # Runs at 9 AM in the specified timezone
        timezone="America/New_York"  # Specify your desired timezone
    )
)

# Deploy the deployment
deployment.deploy()
Key points: - Use the
timezone
parameter in the
Cron
class constructor - Timezone should be specified in IANA tzdata format (e.g., "America/New_York", "Europe/London", "Asia/Tokyo") - The schedule will automatically handle Daylight Savings Time adjustments if applicable - If no timezone is specified, the system default timezone will be used Common timezone examples: -
America/New_York
-
America/Los_Angeles
-
Europe/London
-
Asia/Tokyo
-
UTC
You can find a complete list of valid timezone names in the IANA Time Zone Database. Since you're using a self-hosted Prefect server deployed via Helm chart, make sure your server's timezone settings are properly configured if you want the server's local time to match your expectations.