Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

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. Pass null to unset time zone.

Input/output types:

inputoutput
anyany

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 │ 2 weeks ago │
│ 1 │ 2 weeks 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 │ 2 weeks ago │
│ 1 │ 2 weeks ago │
╰───┴─────────────╯