Question

Change Local Time Zone?

Posted February 27, 2020 198 views
NginxUbuntu 18.04

Hi there,

I acted before thinking this through. I was working in my WordPress (LEMP) site and noticed the time was off. Instead of making the Local Timezone fix in Settings > General as one normally does, I tried changing it through SSH.

This is my current configuration for $ timedatectl

                      Local time: Thu 2020-02-27 16:34:51 EST
                  Universal time: Thu 2020-02-27 21:34:51 UTC
                        RTC time: Thu 2020-02-27 21:34:52
                       Time zone: UTC (EST, -0500)
       System clock synchronized: yes
systemd-timesyncd.service active: no
                 RTC in local TZ: no

My WordPress General Settings now shows:

Universal time is 2020-02-27 16:28:00. Local time is 2020-02-27 16:28:00.

So, I’m guessing the (EST, -0500) for Time zone: UTC (EST, -0500) is coming from Local time.

When I check $ date it shows me the local EST time instead of the UTC that I’m looking for.

Despite how easy it was to mess this up, I can’t seem to undo the change.

Any advice would be greatly appreciated.

TIA!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @aerynlynne,

The system timezone is configured by symlinking /etc/localtime to a binary timezone identifier in the /usr/share/zoneinfo directory. Alternatively, you can also check the current system’s timezone by displaying the contents of the /etc/timezone file.

cat /etc/timezone

There are a few possibilities to change the timezone. The first one is using timedatectl

timedatectl list-timezones

You’ll something like

Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara

Once you identify which time zone is accurate to your location, run the following command:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s timezone to Europe/Rome:

sudo timedatectl set-timezone Europe/Rome ```

Run the timedatectl command to verify the changes

Regards,
KDSys
  • Hi KDSys,

    Thanks for the info, but it doesn’t answer my issue though. (It’s pretty much the same answer you gave for https://www.digitalocean.com/community/questions/timestamp-for-local-time as well.)

    I’ve already gone through timedatectl and can’t seem to change Local Time to UTC.

    OR alternatively, have Time Zone: UTC not include EST.

    cat /etc/timezone does show UTC, but that’s not affecting the area I need changed.

    • Hi @aerynlynne,

      If you run the command I gave in my previous reply

      sudo timedatectl set-timezone UTC
      

      What happens? Does it give an error or just nothing changes?

      • Hi @KDSys,

        I’ve tried that line repeatedly. It only partially affects the Timezone line, but not the area that I needed changed (the area within the brackets is what I need to affect).

        I’ve figured out what’s going on, and have created a band-aid of sorts.

        This is my latest result:

                              Local time: Sat 2020-02-29 23:04:40 GMT
                          Universal time: Sat 2020-02-29 23:04:40 UTC
                                RTC time: Sat 2020-02-29 23:04:41
                               Time zone: UTC (GMT, +0000)
               System clock synchronized: yes
        systemd-timesyncd.service active: yes
                         RTC in local TZ: no
        

        The first article I read on changing timezones, discussed this method:

        cp /usr/share/zoneinfo/Choice_Of_Zone /etc/localtime

        Which, I’ve since learned is so wrong.

        Because while it changed the Local time as requested, it also changed the overall Time Zone which is not optimal.

        Since I still can’t get it to accept UTC for the Local time (the error message taught me that /usr/share/zoneinfo/UTC file and the /etc/localtime file are the same), I chose GMT for the local timezone and will cross-fingers that this doesn’t cause issue for my WordPress installations in the future.

        Thanks for your help,

        Aeryn

        • Hi @aerynlynne,

          That’s a pretty good band aid to be honest, I’ll try and recreate your problem on my enviroment so that I can debut it more.

          As soon as have any more suggestions, I’ll do a followup here.

Submit an Answer