If we provide the name of timezone region like "America/Phoenix"
, is there any way to get the current date and time in C#?
I have tried the following code:-
TimeZoneInfo ZoneName = System.TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time");
DateTime dataTimeByZoneId = System.TimeZoneInfo.ConvertTime(DateTime.Now,System.TimeZoneInfo.Local, ZoneName);
but it takes/expects the input as "US Standard Time Zone"
.
I want the input to be as "America/Phoenix"
. Please do let me know if we have any options/method in C# to achieve this?