EN
C# / .NET - current time zone offset
13 points
In C# / .NET it is possible to get time zone with TimeZoneInfo
class.
xxxxxxxxxx
1
TimeZoneInfo zone = TimeZoneInfo.Local;
2
3
Console.WriteLine(zone.DisplayName);
4
Console.WriteLine(zone.BaseUtcOffset);
Output:
xxxxxxxxxx
1
(UTC+00:00) Dublin, Edinburgh, Lisbon, London
2
00:00:00
Notes:
- Example has been run from London in United Kingdom.
- Do not use
TimeZone
class because is obsolete.TimeZoneInfo.BaseUtcOffset
property returns difference between current time and UTC.
- C# / .NET - get current timezone