polars convert-time-zone for dataframe
Convert datetime to target timezone.
This command requires a plugin
The polars convert-time-zone command resides in the polars plugin. To use this command, you must install and register nu_plugin_polars. See the Plugins chapter in the book for more information.
Signature
> polars convert-time-zone {flags} (time_zone)
Parameters
time_zone: Timezone for the Datetime Series. Passnullto unset time zone.
Input/output types:
| input | output |
|---|---|
| polars_expression | polars_expression |
Examples
Convert timezone for timezone-aware datetime
> ["2025-04-10 09:30:00 -0400" "2025-04-10 10:30:00 -0400"] | polars into-df
| polars as-datetime "%Y-%m-%d %H:%M:%S %z"
| polars select (polars col datetime | polars convert-time-zone "Europe/Lisbon")
╭───┬──────────────╮
│ # │ datetime │
├───┼──────────────┤
│ 0 │ 6 months ago │
│ 1 │ 6 months ago │
╰───┴──────────────╯Timezone conversions for timezone-naive datetime will assume the original timezone is UTC
> ["2025-04-10 09:30:00" "2025-04-10 10:30:00"] | polars into-df
| polars as-datetime "%Y-%m-%d %H:%M:%S" --naive
| polars select (polars col datetime | polars convert-time-zone "America/New_York")
╭───┬──────────────╮
│ # │ datetime │
├───┼──────────────┤
│ 0 │ 6 months ago │
│ 1 │ 6 months ago │
╰───┴──────────────╯