LinuxCommandLibrary

tzselect

Select a timezone interactively

TLDR

Open the interactive menu for timezone selection and print the selected timezone to stdout

$ tzselect
copy

Ask for nearest timezone to coordinates in ISO 6709 notation
$ tzselect -c [coordinates]
copy

SYNOPSIS

tzselect

DESCRIPTION

The tzselect command provides an interactive way to select a timezone from a geographical hierarchy. It guides the user through a series of questions, starting with continents or ocean regions, and progressively narrowing down the selection until a specific timezone is chosen. This is useful for configuring the TZ environment variable, which controls how dates and times are displayed. The command outputs the selected timezone string that can then be used to set the TZ variable directly, or it can be incorporated into system configuration files (e.g., /etc/timezone). tzselect does not directly modify system settings; it simply provides the correct timezone string for you to use.

While some systems have graphical timezone configuration tools, tzselect is a reliable and universally available method, especially for systems accessed through a terminal or remote connection. It relies on the tz database, also known as the IANA timezone database, maintained regularly, ensuring accuracy. The output is meant to be portable, and is meant to be used on any POSIX compliant OS. Once the timezone is selected the value is printed to standard out.

CAVEATS

tzselect relies on the user's correct answers to geographical questions. An incorrect selection will lead to the wrong timezone being chosen. It does not modify system configuration directly. Setting the TZ environment variable only affects the current shell session unless applied persistently. It requires interaction and cannot be used non-interactively. The command only handles timezone selection and does not deal with other aspects of time configuration, such as NTP.

<B>USING THE OUTPUT</B>

The output of tzselect is the timezone string. To set your timezone for the current session, you can use: export TZ='$(tzselect)'; date
To make this permanent, add this line to your .profile or similar shell configuration file.

<B>ERROR HANDLING</B>

tzselect itself doesn't have a lot of error handling. However, wrong input can lead to weird timezone settings, so be careful while you select the needed timezone.

HISTORY

tzselect has been a standard utility on Unix-like systems for many years. It was originally designed to simplify timezone configuration for users who may not be familiar with the complexities of the tz database or the specific timezone naming conventions. The command's primary purpose has always been to provide an interactive and user-friendly method for selecting a timezone from a hierarchical geographical structure. It continues to be a valuable tool for configuring timezones, especially in environments where graphical interfaces are not available.

SEE ALSO

timedatectl(1), date(1)

Copied to clipboard