Manually set date and time on NixOS

Since timedatectl can’t be used, in order to change NixOS system time manually, there are two ways I found.

  1. Use hwclock --date "1970-01-01" --set then sync with system clock hwclock -s.
  2. Use date -s "1970-01-01"

But, both of the command must be executed after disable systemd-timesyncd.service.

sudo systemctl stop systemd-timesyncd.service

I found it nowhere in the Internet that works, so I made this notes anyone looking for it in the future (myself?).

5 Likes

Thanks a lot, it saved me with issues with SSL certificates ! For format with minutes: date --set="20221231 05:30" is the 31 december 2022 at 05:30

Hosted by Flying Circus.