In my .bashrc file I configured how I would like my prompt to be displayed. My .bashrc is sourced in .bash_profile. The command in the .bashrc file is:
PS1='[\t] \u@\h is $PWD :: '
I switched the user (for me) timezone to GMT+0 using tzselect. The problem I am having is that using the date command I am getting the GMT time (which I am pleased with) but the terminal prompt is still on the system time (even after logging in and logging out), which I am not pleased with.
How can I get the terminal to display the time in the time format that I, the user, am specifying?
Best Answer
You don't say how you set the timezone, but since you set it for your own user, that has to be by setting the
TZ
variable. Bash (at least version 4.1.5) has some quirks when it comes to taking aTZ
change into account: the change is only reflected after the shell has started an external command (it has to be an external command, forking a subshell isn't enough, nor is executing built-ins).So if you set
TZ
in your.bash_profile
and you don't happen to start an external command, you will still see the time in the old timezone at the first prompt.