System time

The system time backed by the system clock is used in Unix systems to keep track of time. It can be set by a hardware clock or by an external time server.

Software clock vs Hardware clock
The system clock, provided by the kernel, is implemented as a simple count of the number of ticks that have transpired since the 1 January 1970 00:00:00 UT. This is called Unix time.

The hardware clock (also known as real-time clock or RTC) is typically a component on the mainboard. It runs independent of the state of the operating system all the time, also when the computer is shutdown.

UTC time vs localtime
The time for hardware clock can be modified to represent two standards: localtime or UTC time. The localtime is the real time of the time zone including DST. Preferred is UTC time because the system time gets computed by adding the time zone difference and DST. So daylight saving changes get automatically applied and changing the time zone are possible without changing the hardware clock. Exceptions can be made when using a dual-boot system; this is when the other operating system does not support or is not configured for an UTC hardware clock (by default, Windows uses localtime).

Time zone
In order to keep time properly, select the proper time zone so the system knows where it is located.

OpenRC
Look for the local time zone in. Please avoid the time zones as their names do not indicate the expected zones. For instance, is in fact GMT+8. For localtime select the "localtime" time zone.

After zone info has been selected, set the time zone in, e.g. for Germany:

The information in this file is used by on each package update to copy the chosen zoneinfo file to. To setup this file out of order, run:

systemd
systemd comes with the timedatectl to manage the time zone:


 * To check the current zone:


 * To list available zones:


 * To change the time zone, e.g. for Germany:

System clock
Typically the system clock time is set up by the hardware clock on boot. Alternatively it is possible to manually set the system clock or use a network time server.

The date command can be used to manage the system clock time:


 * To check the current software clock time:


 * To set the system clock, e.g. 12:30, Dec. 17, 2012:

Time server
See the NTP article.

systemd
systemd comes with the timedatectl command to manage the system clock time:


 * To check the current software clock time:


 * To set the system clock:

Hardware clock
Typically the hardware clock is used to setup the system clock on boot. This can be done by the kernel itself or by a boot service. Also on shutdown the kernel or a service can write the software clock to the hardware clock.

Kernel
The following kernel options must be activated:

At runtime, to check the current hardware clock time:

To set the hardware clock to the current system clock:

OpenRC
The service hwclock setup the system clock on boot and sync the hardware clock on shutdown. The service is enabled by default.

By default the service is configured for UTC time standard. To change to localtime edit the file:

systemd
systemd can be used to set the system clock on boot. Use timedatectl to manage the hardware clock:


 * To check the current hardware clock time:


 * To set the hardware clock to the current system clock (UTC time standard):


 * To set the hardware clock to the current system clock (localtime time standard):

External resources

 * Dual booting with MS Windows, set RealTimeIsUniversal