-1

I am trying to synch the hour between localtime and RTC. I have DS3231 RTC, i followed a guide to install and configure the OS to use it, RTC is working, but the time without internet is 2 hours backwards. My timezone is GMT+2 and its set correctly in /etc/localtime. When NTP is working everything is looking fine. Output of timedatectl:

   Local time: Mon 2019-11-18 11:42:28 EET
  Universal time: Mon 2019-11-18 09:42:28 UTC
        RTC time: Mon 2019-11-18 09:42:29
       Time zone: Etc/UTC (EET, +0200)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

When i unplug the ethernet cable and restart raspberry, the local time is moving automaticly from 11:42 to 9:42

How to fix this problem? Thank you.

PS: I tried with this shell script manually to enter the hour of RTC:

newhour=$(date +%T --date '2 hours');
curdate=$(date '+%d %b %Y')
settime="$curdate $newhour"
echo $settime
sudo hwclock --set --date "$settime"

But NTP is fixing the value stored in RTC...

Siddharth Kaul
  • 871
  • 10
  • 20

1 Answers1

0

welcome to stackoverflow!

To set your OS timezone in the system configuration you have to define it with timedatectl. For example for Bulgaria you have to enter

sudo timedatectl set-timezone Europe/Sofia

To check it, you could do a

cat /etc/timezone

You should now always have the correct timezone (UTC+2 or UTC+3 for daylight saving time in Bulgaria), no matter if you have an internet connection established or not.

NTP is just used to perpetually synchronize the system time with a time server.

Hope this helps!

digijay
  • 1,329
  • 4
  • 15
  • 25
  • Actually this works, but right now (don't know why) the synch is not working. When i left the device powered off for 20 min and then switching it on, the time is 20 minutes backward. – Tsvetomir Tsvetanov Nov 27 '19 at 13:54