Using Debian for some time now, I faced this problem and could not find a solution for it. Well now I’ve found it and would like to share!
Most PCs have a hardware clock (RTC clock) for keeping time. Linux distributions like Debian and Arch recommend saving the hardware clock to UTC, while in Windows and most other operating systems set it to local time. This creates the problem between time settings of Debian/LMDE and Windows/Other OS.
To fix this, we will follow the procedure below:
Configure Linux to use RTC Clock as localtime
First of all check whether the hardware clock is set to local time or UTC using the command-
sudo hwclock -D # for newer distros its hwclock -v
This will show the system time (Operating System time), Hardware clock time and whether hardware clock is set to localtime. By default in Debian Hardware clock is set to UTC.
Now assuming your system time is correct, write it to the hardware clock and set hardware clock to localtime, use the command-
sudo hwclock -w --localtime
This will set the current system time to hardware clock and configure the hardware clock to localtime.
Make sure system timezone is correct
If your system time is not correct, first of all make sure your time zone is set correctly by using the command-
sudo dpkg-reconfigure tzdata
Now if the system time is correct, go to previous step and set system time to hardware clock
Otherwise to manually set the system time use the date command-
date -s “1 JUL 2013 20:30:00”
The hardware clock time and type can be set directly using following syntax-
hwclock --set --date='07/23/13 21:10:00' --localtime
[Optional] Disable sync to hardware clock on shutdown
I have Debian installed on an external disk, and don’t like to save the system time to hardware clock as it causes issues with existing systems. To prevent Debian from doing that, edit the file /etc/default/hwclock as-
sudo nano /etc/default/hwclock
and set HWCLOCKACCESS=NO
(also make sure that the line is uncommented)
Now at shutdown it will say-“Not Saving the System Clock”
Update (May 2021) – With Debian 11 Bullseye, the above method does not seem to work, the hardware clock gets periodically synchronized anyway. Searching for a solution; if you find one please drop a comment!
Alternate solution: configure Windows to use hardware clock as UTC
- Configure Windows to use Hardware clock time as UTC
To make MS Windows calculate the time from the hardware clock as UTC. Create a file named WindowsTimeFixUTC.reg with the following contents and then double click on it to merge the contents with the registry:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTimeZoneInformation] "RealTimeIsUniversal"=dword:00000001
- Set Linux distributions to use Hardware clock time as UTC by-
sudo hwclock -w --UTC
I’ve tried editing /etc/default/rcS and setting UTC=no as posted on many sites but it did not work for me.