Change default timezone in ASP.NET Core 2.2 on Docker for 24h time format

Found out that we need to set the language, since this is used for the formatting:

ENV TZ=Europe/Berlin
ENV LANG de_DE.UTF-8
ENV LANGUAGE ${LANG}
ENV LC_ALL ${LANG}

This works and produces German 24h DateTime formattings.

I agree that in most cases this should be controlled by the application, which use different formattings on e.g. user specified settings. Since this is a simple application only for me, it's the easiest way to set the server settings to my localisation. Passing a culture info from any kind of settings would produce overhead without advantage.

But as I said this is only suiteable for my case. In a productive environment you may want to specify the colture and allow different cultures for international users.


The formatting of the "general" date/time is governed by the machine or process locale not the timezone. It should never be relied on to produce a specific format. Either set the CultureInfo, or specify the exact format you want:

Publishedtime.ToString("g",CultureInfo.CreateSpecificCulture("de-DE"))
Publishedtime.ToString("dd.MM.yyyy HH:mm"))