Use Python to find out if a timezone currently in daylight savings time [duplicate]

import pytz
from datetime import datetime, timedelta

def is_dst(zonename):
    tz = pytz.timezone(zonename)
    now = pytz.utc.localize(datetime.utcnow())
    return now.astimezone(tz).dst() != timedelta(0)

Usage:

>>> is_dst("America/Los_Angeles")
False

>>> is_dst("America/Sao_Paulo")
True

Leave a Comment