WSL: Wrong Date

When checking the date in WSl, it display the wrong date

❯ date
Wed Jul 26 15:28:20 CEST 2023

So setup the correct date, you could run either

❯ sudo hwclock -s

or setup a timesync daemon (described here)

Add these lines to the /etc/wsl.conf (note you will need to run your editor with sudo privileges, e.g: sudo nano /etc/wsl.conf):

[boot]
systemd=true

And close out of the nano editor using CTRL+O to save and CTRL+X to exit. Now close your WSL distro windows and run wsl.exe --shutdown from PowerShell, then restart your WSL instance. Upon launch you should have systemd running.

Now install systemd-timesyncd:

sudo apt install systemd-timesyncd
sudo systemctl edit systemd-timesyncd

In the second step, when editing, add the two lines beginning with [Unit], as shown below:

Now start it:

sudo systemctl start systemd-timesyncd

Check status with:

timedatectl status
timedatectl timesync-status