Languages
[Edit]
EN

C# / .NET - current time zone offset

13 points
Created by:
Marcin
2477

In C# / .NET it is possible to get time zone with TimeZoneInfo class.

1. TimeZoneInfo class example

TimeZoneInfo zone = TimeZoneInfo.Local;

Console.WriteLine(zone.DisplayName);
Console.WriteLine(zone.BaseUtcOffset);

Output:

(UTC+00:00) Dublin, Edinburgh, Lisbon, London
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.

References

  1. TimeZoneInfo Class - Microsoft Docs
  2. Coordinated Universal Time (UTC) - Wikipedia

Merged questions

  • C# / .NET - get current timezone
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.