How to get timezone name in different language C# on Azure

Viewed 1429

I am currently getting TimeZone using

 string TimeZoneName = "Indian Standard Time";
 var tz = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneName);

It is currently returning the desired value in English even if I change the Current culture and I am currently testing the code on Azure (Web App Service). Please help me to find a way in which I can get the code to return value in Different language like Arabic, French, etc.

3 Answers
TimeZoneInfo timeZone = TimeZoneInfo.GetSystemTimeZones().SingleOrDefault(z => z.DaylightName == TimeZone.CurrentTimeZone.DaylightName);

This will return the current timezone based on the OS language.

You can install the nuget package : https://github.com/mj1856/TimeZoneNames

PM> Install-Package TimeZoneNames

It' a simple library that provides localized time zone names using CLDR and TZDB sources.

Example:

var names = TZNames.GetNamesForTimeZone("Romance Standard Time", "en-GB");

names.Generic == "Central European Time"
names.Standard == "Central European Standard Time"
names.Daylight == "Central European Summer Time"
Related