WSL date and time out of sync

wsldate-timeissue
Aug 20, 2023

Problem

WSL data/time is out of sync with Windows or the actual time.

Solution 1

Run below command in WSL terminal:

sudo hwclock -s

Solution 2

Sometimes, the above solution doesn't work.
Then go the hard way.

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

HIH
~ RD