daft.functions.convert_time_zone#
convert_time_zone #
convert_time_zone(expr: Expression, to_timezone: str, from_timezone: str | None = None) -> Expression
Converts a timestamp to another timezone while preserving the instant in time.
If the timestamp has no timezone, from_timezone must be provided to interpret the local time before converting to to_timezone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr | Expression | Timestamp expression to convert. | required |
to_timezone | str | Target timezone (e.g. "UTC", "+02:00", "America/New_York"). | required |
from_timezone | str | None | Source timezone for timestamps without a timezone. | None |
Returns:
| Name | Type | Description |
|---|---|---|
Expression | Expression | Timestamp expression with the target timezone. |
Source code in daft/functions/datetime.py
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 | |