tzselect Command in Linux



The tzselect is an interactive command in Linux that is used to select the timezone. It does not set the system time zone but helps identify the correct time zone string based on geographic selections.

Table of Contents

Here is a comprehensive guide to the options available with the tzselect command −

Syntax of tzselect Command

The syntax of the tzselect command in Linux is as follows −

tzselect [options]

The [options] field in the syntax is used to specify various options to change the output, such as displaying the help message and version.

tzselect Command Options

The options of the tzselect command in Linux are listed below −

OptionsDescription
-c coord

Select time zones by proximity to coordinates (coord) in ISO 6709 format (example: +40.689-074.045).

- Latitude and longitude are signed, optional decimal.

- Degrees (DD/DDD), minutes (MM), seconds (SS) supported in various formats (example: +4041.4-07402.7).

-n limitWhen used with -c, limits the number of closest time zone results (default: 10).
--helpDisplays help information and exits.
--versionDisplays version information and exits.

Examples of tzselect Command in Linux

This section explains how to use the tzselect command in Linux with examples −

  • Selecting a Timezone Interactively
  • Selecting a Timezone by Coordinates
  • Limiting the Number of Nearest Timezones
  • Displaying Usage Help

Selecting a Timezone Interactively

To select a timezone interactively, use the tzselect command without any option −

tzselect

The above command prompts step-by-step for the continent, country, and then region or city.

tzselect Command in Linux1

Selecting a Timezone by Coordinates

To select a timezone by coordinates, use the -c option followed by coordinates. For example, to look up time zones near 40.689° N, 74.045° W (New York area), use the following command −

tzselect -c +40.689-074.045

To convert the degrees in longitude and latitude in ISO 6709 (±[latitude][±longitude]), use the following calculation −

Latitude

  • 40.689° N > +40.689
  • Pad to 2 digits before decimal: +40.689

Longitude

  • 74.045° W > −74.045
  • Pad to 3 digits before decimal: -074.045
tzselect Command in Linux2

Limiting the Number of Nearest Timezones

By default, the 10 closest time zones around a specific zone are listed. To reduce the number of listed nearby time zones, use the -n option followed by a number. For example, to limit it to 5 only, use the tzselect command in the following manner −

tzselect -c +4041.4-07402.7 -n 5
tzselect Command in Linux3

Displaying Usage Help

To display the usage help message of the tzselect command, use the --help option −

tzselect --help

Conclusion

The tzselect command in Linux provides an interactive way to determine the correct time zone based on geographic location or coordinates. It does not apply changes to the system but helps identify the appropriate time zone string. The command supports several options, such as selecting by coordinates and limiting the number of results, and includes flags for displaying help or version information.

In this tutorial, we covered the tzselect command, its syntax, options, and usage in Linux with examples.