A while ago I ran into a timezone-related headache: daylight saving time had kicked in on a server, and automated jobs were shifting by an hour. The server was overseas, so the local timezone differed from mine, and figuring out what “now” meant on the remote side required constant mental arithmetic.

That sent me down a rabbit hole. Should a remote server be set to my local timezone, the server’s geographical timezone, or something else entirely?

The answer, backed by a thorough post from Yeller, is unambiguous: use UTC. Servers in UTC never have DST surprises, their logs are unambiguous, and any timestamps stored in databases or log files can be reliably compared across systems. Every tool and framework in the linked post (from PostgreSQL to Django to Ruby on Rails) recommends or defaults to UTC for a reason.

After switching all my servers to UTC, I needed to solve the usability problem: I still wanted to see my local time in the terminal without having to do timezone math in my head.

Displaying local time in a UTC environment Link to heading

Option 1: Set TZ in your shell Link to heading

Add to your ~/.zshrc (or ~/.bashrc):

export TZ=/usr/share/zoneinfo/Europe/Rome

With TZ set, tools that respect it (date, journalctl, and most well-written programs) will display times in your local timezone:

# Without TZ:
% date
Mon Mar 25 20:56:43 2019

# With TZ set:
% date
Mon Mar 25 21:57:53 CET 2019

journalctl also shows localized timestamps when TZ is set, which makes reading logs much more natural.

Option 2: Show local time in the tmux status bar Link to heading

I run everything in tmux sessions. After switching servers to UTC, the tmux clock in my status bar started showing UTC time. To display the timezone in the status bar:

In ~/.tmux.conf:

set -g status-right '%a %b %d %H:%M %Z'

The %Z token shows the timezone abbreviation (e.g., CET or CEST depending on DST), which gives you a quick sanity check.

Option 3: Propagate TZ over SSH Link to heading

For this to work on a remote server, the TZ variable needs to travel with you over SSH. Configure your SSH client to send it:

In ~/.ssh/config:

Host *
  SendEnv TZ

And configure the SSH server to accept it:

In /etc/ssh/sshd_config:

AcceptEnv LANG LC_* TZ

Restart sshd after the change. Now when you SSH into a remote server, your local TZ variable is forwarded; tmux picks it up, and the status bar clock shows your local time while the server itself remains on UTC.