Get timezone from DateTime

前端 未结 7 2305
Happy的楠姐
Happy的楠姐 2020-12-04 22:49

Does the .Net DateTime contain information about time zone where it was created?

I have a library parsing DateTime from a format that has \"+zz\" at the end, and wh

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 23:41

    You could use TimeZoneInfo class

    The TimeZone class recognizes local time zone, and can convert times between Coordinated Universal Time (UTC) and local time. A TimeZoneInfo object can represent any time zone, and methods of the TimeZoneInfo class can be used to convert the time in one time zone to the corresponding time in any other time zone. The members of the TimeZoneInfo class support the following operations:

    1. Retrieving a time zone that is already defined by the operating system.

    2. Enumerating the time zones that are available on a system.

    3. Converting times between different time zones.

    4. Creating a new time zone that is not already defined by the operating system.

      Serializing a time zone for later retrieval.

提交回复
热议问题