linuxtimezonecentos7zoneinfotzdata

How to set half hour and 45-minute time zones without worrying about DST changes in Linux?


Currently I am setting time zone GMT+5 on my Linux CentOS 7 machine by linking /etc/localtime to /usr/share/zoneinfo/Etc/GMT-5.

I want to create a zone info file for example /usr/share/zoneinfo/Etc/GMT-5:30 that enables me to set the current timezone to GMT+5:30 without having to worry about DST changes.

I am aware that I could link /etc/localtime to /usr/share/zoneinfo/Asia/Kolkata for example but then I will have to worry about DST changes even if it may not be implemented in the mean time.

Also I am aware of TZ=GMT+5:30; export $TZ but I am worried that this approach backfire for some reason in the future.


Solution

  • If you don't want to use $TZ variable, you may want to create your own timezone file.

    You need create a text file (say MyZone.zic) with

    Zone MyZone 5:30 - GMT-5:30
    

    then run

    zic -d <desired_folder> MyZone.zic
    

    then link compiled file to /etc/localtime