microsoft / microsoft/WSL

[WSL2] [bug] The Systemd timezone is reset to the Windows timezone at boot time. Some users may have reasons to use UTC.

Open
#6,417 11 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Is your feature request related to a problem? Please describe.
My Windows timezone is set to CET.
We're running some software in an Ubuntu 20.04 WSL2 machine that needs the timezone to be set to UTC.
I tried to set the timezone using sudo dpkg-reconfigure tzdata > "None of the above" > "UTC".

Problem: This works, but the timezone is reverted to the Windows timezone after WSL2 reboot.

Describe the solution you'd like
Possibility to persistently & easily configure a timezone in WSL2 that differs from the Windows timezone.
Could e.g. be added to /etc/wsl.conf.

Describe alternatives you've considered
Didn't find any related option here:
https://devblogs.microsoft.com/commandline/automatically-configuring-wsl/

Currently using this workaround (to avoid the console-UI tool dpkg-reconfigure):

	echo "Previous timezone: $(< /etc/timezone), $(readlink /etc/localtime)"
	timezone="Etc/UTC"
	zoneinfo="/usr/share/zoneinfo/$timezone"
	echo "Updating /etc/timezone: $timezone"
	echo "$timezone" | tee /etc/timezone
	echo "Updating /etc/localtime -> $zoneinfo"
	rm -f /etc/localtime
	ln -s "$zoneinfo" /etc/localtime

Additional context
n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the requested /etc/wsl.conf configuration and the boot-time timezone reset described in the issue; compare it with the current dpkg-reconfigure and shell workaround. Done means users can configure a timezone different from Windows and that choice persists across WSL2 reboots.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, ubuntu
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.