Get TimeZone Id with Current Local dateTime annd GMT datetime RRS feed

  • Question

  • Hello,

    How can i get the TimeZone Id in c#. I have the DateTime in GMT and local DateTime or the offset value in minutes.

    Jameson M Tinoy

    Monday, October 15, 2018 1:55 PM

All replies

  • There are multiple timezones with the same offsets so given an offset you cannot get to the timezone for it (as there may be multiples). Refer to MSDN for more information.

    You can get the local timezone using TimeZonInfo.Local. You can get the available time zones on a machine using GetSystemTimeZones. You can create custom time zones using CreateCustomTimeZone. Given an offset you could get the list of matching time zones, ignoring daylight savings time issues.

    It is unclear to me what you're trying to do with the UTC and local times. You can convert one to the other using the standard DateTime methods. For example if you wanted to know the difference between 2 times then convert them to UTC and then compare them.

    If you have a DateTime with no time zone information (typical) but you know what timezone it is in then you can use the ConvertTime method.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, October 15, 2018 5:43 PM