Is there a way to check which time zone I'm currently in on Linux?
Best Answer
Usually, the TZ environment variable will tell you something useful. However, it is best to use functions such as mktime() and localtime() to convert between time_t and a local timezone representation. That is, don't try to do the conversion yourself.
Zones like Etc/GMT+6 are intentionally reversed for backwards compatibility with POSIX standards. See the comments on Wikipedia, and in this file from the tzdb.
You should almost never need to use these zones. Instead you should be using a fully named time zone like America/New_York or Europe/London or whatever is appropriate for your location. Refer to the List of tz database time zones on Wikipedia.
Best Answer
Usually, the
TZ
environment variable will tell you something useful. However, it is best to use functions such asmktime()
andlocaltime()
to convert betweentime_t
and a local timezone representation. That is, don't try to do the conversion yourself.