'How do I make Tmux display time in a different time zone?
Hitting <tmuxPrefix> + t displays the time on my server but I want it to display the time in my current timezone rather than the server's timezone.
I run into the same issue when I want to display the time in the status bar in my current timezone.
I was able to partially fix it by using the following command:
set -g status-right '#(TZ="Asia/Kolkata" date )'
But when I use modifiers like %H, %M, %S in the status, as below, it ends up showing the time in the server's time zone.
set -g status-left '%H:%M:%S'
I have updated my .bashrc config with TZ="Asia/Kolkata". This gives me time in the right timezone when I run the time command in bash but it doesn't seem to use the variable in a Tmux session.
Can anyone please let me know how I can fix it?
Solution 1:[1]
For the second part of your question, you can use:
set -g status-right '#(TZ="Asia/Kolkata" date +%%H:%%M:%%S)'
Solution 2:[2]
What I do is set the timezone for my user. It works beyond tmux, it will translate anything that displays dates and times, like the output of 'ls' for example.
Edit your ~/.profile and set the TZ variable, for example:
export TZ=/usr/share/zoneinfo/US/Pacific
You can also make ssh send your current timezone automatically. Make sure you have TZ in the ~/.profile of your laptop then instruct ssh to send it by adding this to ~/.ssh/config
SendEnv TZ
The remote server has to be configured to accept it, if it doesn't work make sure it has this in /etc/ssh/sshd_config
AcceptEnv LANG LC_* TZ
Solution 3:[3]
If you have white space in the datetime format you can use:
set -g status-right '#(TZ="Asia/Kolkata" date +"%%h %%d %%H:%%M")'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steven Tian |
| Solution 2 | GiBaTr0n |
| Solution 3 | Angel Balashev |
