Create a Custom or Disable DST(daylight-saving time) in RHEL/CentOS Linux

A few weeks ago, it is announced (by The Energy and Natural Resources Ministry of Iran) that DST will be permanent and GMT+3:30(IRST) will be used forever in the country. From 2023, Iran will not set their clocks forward for Daylight Saving Time (DST) but remain on standard time permanently.

Based on following manual, we are going to create a custom timezone file for Iran +3:30 and disable DST:

### Create custom TZ file
[root@testos]# vi custom_timeZone_IR
###Add following lines for Disable DST in Iran.

#Zone NAME           GMTOFF RULES/SAVE  FORMAT [UNTIL]
Zone  Iran-noDST   3:30   -           IRST   2022 Mar 22 00:00
                   3:30   -           IRST

### Creates the time conversion information file				   
[root@testos]# zic -d . custom_timeZone_IR

[root@testos]# ls
custom_timeZone  Iran-noDST

### Check the value of generated file
[root@testos]# zdump -v Iran-noDST
Iran-noDST  -9223372036854775808 = NULL
Iran-noDST  -9223372036854689408 = NULL
Iran-noDST  9223372036854689407 = NULL
Iran-noDST  9223372036854775807 = NULL

### Copy new tz file to zoneinfo location
[root@testos]# cp Iran-noDST /usr/share/zoneinfo/Etc/

### Set required permission
[root@testos]# chmod 644 /usr/share/zoneinfo/Etc/Iran-noDST

### Check Current time/date configuration
[root@testos]# timedatectl
      Local time: Mon 2022-12-05 23:31:51 +0330
  Universal time: Mon 2022-12-05 20:01:51 UTC
        RTC time: Mon 2022-12-05 20:01:51
       Time zone: Asia/Tehran (+0330, +0330)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Wed 2022-09-21 23:59:59 +0430
                  Wed 2022-09-21 23:00:00 +0330
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Tue 2023-03-21 23:59:59 +0330
                  Wed 2023-03-22 01:00:00 +0430


### Check current timezone configuration	  
[root@testos]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 33 Jan  1  2021 /etc/localtime -> ../usr/share/zoneinfo/Asia/Tehran

### Remove link
[root@testos]# rm /etc/localtime
rm: remove symbolic link ‘/etc/localtime’? y

### Create link for new tz file
[root@testos]# ln -sf /usr/share/zoneinfo/Etc/Iran-noDST /etc/localtime

### Check new timezone configuration
[root@testos]# ls -l /etc/localtime
lrwxrwxrwx 1 root root 34 Dec  5 23:23 /etc/localtime -> /usr/share/zoneinfo/Etc/Iran-noDST

### Check new time/date configuration (No DST)
[root@testos]# timedatectl
      Local time: Mon 2022-12-05 23:33:25 IRST
  Universal time: Mon 2022-12-05 20:03:25 UTC
        RTC time: Mon 2022-12-05 20:03:24
       Time zone: Etc/Iran-noDST (IRST, +0330)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

2 thoughts on “Create a Custom or Disable DST(daylight-saving time) in RHEL/CentOS Linux”

Leave a Comment