flexter
flexter

Reputation: 117

How can we show a time different from system time in Bash prompt?

I have system time in PDT timezone in my CentOS machine but I want my bash prompt to display IST time without changing the system time. How can I set my PS environment variable to do that?

Upvotes: 3

Views: 1163

Answers (1)

Calvin Kim
Calvin Kim

Reputation: 364

PS1="[\$(TZ='Asia/Kolkata' date '+%F %T %Z') \u@\h \W]\n\$ "

\$(TZ='Asia/Kolkata' date '+%F %T %Z') returns current time in IST.

Ref.: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html

Upvotes: 5

Related Questions