Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get time zone as a String in C# ?

I need to get time zone of PC as below format.

(UTC+07:00) Bangkok, Hanoi, Jakarta

How can I get it as a string ?

like image 966
Sachith Avatar asked Dec 04 '22 01:12

Sachith


1 Answers

Just use the TimeZoneInfo.DisplayName property:

var zone = TimeZoneInfo.Local; // For example
Console.WriteLine(zone.DisplayName);

Or for your precise example:

var zone = TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time");
Console.WriteLine(zone.DisplayName); // (UTC+07:00) Bangkok, Hanoi, Jakarta
like image 181
Jon Skeet Avatar answered Dec 28 '22 12:12

Jon Skeet