Temporarily change timezone to display date/time shown during an SSH session

Is there any way I can customize the timezone (which in turn would change the way the time is displayed) for a given SSH session?

The scenario: I am almost always logged in to a Unix box which is in US and the times shown for every command used (e.g. date modified when using ls) are in the US format. Are there any ways I can change the timezone temporarily for that given session so that I can view the times shown as the command outputs for my timezone (e.g. Japan Time Zone JST)?


Solution 1:

Most programs (except for some ill-behaved GUI programs) use the timezone given by TZ environment variable, if it is set.

To change the timezone for one command:

TZ=Asia/Tokyo ls

To change the timezone for the session:

export TZ=Asia/Tokyo

Good shells (read zsh) provide completion for supported timezone names if you press Tab after TZ=.

If you want to change the time display format (order of elements, names of days and months, and so on), set the environment variable LC_TIME (LC_TIME=jp_JP, I guess).

Solution 2:

Give this a try:

export TZ=Asia/Tokyo