Languages
[Edit]
EN

C# / .NET - current time zone offset

13 points
Created by:
Marcin
15740

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
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join