Dates, Times, and Time Zones
In addition to the basic DateTime structure, the .NET Framework provides the following classes that support working with time zones:
Use this class to work with any time zone that is predefined on a system, to create new time zones, and to easily convert dates and times from one time zone to another. For new development, use the TimeZoneInfo class instead of the TimeZone class.
Use this structure to work with dates and times whose offset (or difference) from UTC is known. The DateTimeOffset structure combines a date and time value with that time's offset from UTC. Because of its relationship to UTC, an individual date and time value unambiguously identifies a single point in time. This makes a DateTimeOffset value more portable from one computer to another than a DateTime value.
This section of the documentation provides the information that you need to work with time zones and to create time zone-aware applications that can convert dates and times from one time zone to another.
In This Section
- Time Zone Overview
Discusses the terminology, concepts, and issues involved in creating time zone-aware applications.
- Choosing Between DateTime, DateTimeOffset, TimeSpan, and TimeZoneInfo
- Finding the Time Zones Defined on a Local System
Describes how to enumerate the time zones found on a local system.
- How to: Enumerate Time Zones Present on a Computer
Provides examples that enumerate the time zones defined in a computer's registry and that let users select a predefined time zone from a list.
- How to: Access the Predefined UTC and Local Time Zone Objects
Describes how to access Coordinated Universal Time and the local time zone.
- How to: Instantiate a TimeZoneInfo Object
Describes how to instantiate a TimeZoneInfo object from the local system registry.
- Instantiating a DateTimeOffset Object
- How to: Create Time Zones Without Adjustment Rules
Describes how to create a custom time zone that does not support the transition to and from daylight saving time.
- How to: Create Time Zones with Adjustment Rules
Describes how to create a custom time zone that supports one or more transitions to and from daylight saving time.
- Saving and Restoring Time Zones
Describes TimeZoneInfo support for serialization and deserialization of time zone data and illustrates some of the scenarios in which these features can be used.
- How to: Save Time Zones to an Embedded Resource
Describes how to create a custom time zone and save its information in a resource file.
- How to: Restore Time Zones from an Embedded Resource
Describes how to instantiate custom time zones that have been saved to an embedded resource file.
- Performing Arithmetic Operations with Dates and Times
- How to: Use Time Zones in Date and Time Arithmetic
Discusses how to perform date and time arithmetic that reflects a time zone's adjustment rules.
- Converting Between DateTime and DateTimeOffset
- Converting Times Between Time Zones
Describes how to convert times from one time zone to another.
- How to: Resolve Ambiguous Times
Describes how to resolve an ambiguous time by mapping it to the time zone's standard time.
- How to: Let Users Resolve Ambiguous Times
Describes how to let a user determine the mapping between an ambiguous local time and Coordinated Universal Time.