≡ Menu

Linux / UNIX: TZ Environment Variable

What is the correct format for a TZ (time zone) environment variable for use with the Linux or UNIX operating system?

The format required for the TZ variable is specified by the operating system using system wide or user specific shell profile file. You can set the TZ and make this change permanent for yourself by appending the line to the file .profile in your home directory; then log out and log in again. In this example, I’m setting my TZ variable (timezone) to Indian standard time (IST) as follows:

export TZ


To display your current date & time, enter:
$ date
Sample outputs:

Sat Jan 29 06:21:38 EST 2011

The timezone is set to EST. To view exact details, enter:
$ cat /etc/sysconfig/clock
Sample outputs:


To set your timezone to IST, enter:

export TZ


export TZ='Asia/Kolkata'

To display date & time according to the TZ variable, enter:
$ date
Sample outputs:

Sat Jan 29 16:54:46 IST 2011

How Do I Make the TZ Changes Permanent?

Edit $HOME/.profile or $HOME/.bash_profile appending the line and then log out and log in again:

TZ='Asia/Kolkata'; export TZ

How Do I Set the Time Zone Using the Posix TZ Format?

You can use the following syntax:

export TZ

In this example, set TZ to GST-10 i.e. set it to a zone named GST that is 10 hours ahead (east) of UTC:

export TZ

How Do I Find Out and View the Installed Timezone under Linux or UNIX?

Many UNIX like operating systems ships with the tzselect utility to view the installed timezone. It comes handy when you want to know what time it is in other countries, or if you just wonder what timezones exist. tzselect is called without any parameters from the shell. It shows a list of about one dozen geographic areas one can roughly recognize as continents. After choosing a geographic area by number, a list of countries and cities in this area will be shown. You can press the [Enter] key to reprint the list. To choose a timezone, just press the number left to it. If your input is invalid, the list will be reprinted. You may press [CTRL] + [C] to interrupt the tzselect at any time.
$ tzselect
Sample outputs:

Fig.01: Setting the TZ variable with the tzselect utility

Fig.01: Setting the TZ variable with the tzselect utility

How Do I Change the Actual Timezone?

The tzselect command will not actually change the timezone for you. Use the redhat-config-date or setup command under RHEL / Fedora / Redhat / CentOS Linux to change the timzone:
# redhat-config-date

Use the dpkg-reconfigure tzdata command under Debian or Ubuntu Linux to achieve the same thing:
$ sudo dpkg-reconfigure tzdata

Under OpenBSD or FreeBSD operating system you can set the timezone by creating softlink to /etc/localtime file.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 3 comments… add one }
  • Makella July 31, 2012, 6:37 pm

    I am not sure if I my linux version supports the TZ variable . How do I find that out ? What versions of linux support this feature ?

  • ahmed October 15, 2012, 7:25 pm

    thank you guys man you guys saved lots of my time!!!

    Thanks a lot.

  • grumpyoldphuker October 13, 2014, 3:13 pm

    $ date

    why do youy lie to people wanting assistance in trying to understand something ??
    this shit does not work fuckhead……………………….

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , , , , , , , , , , ,