Times and Time Zones

In addition to the basic DateTime structure, the .NET Framework provides the following classes that support working with time zones:

  • TimeZone

    Use this class to work with the system's local time zone and the Coordinated Universal Time (UTC) zone. The functionality of the TimeZone class is largely superseded by the TimeZoneInfo class.

  • TimeZoneInfo

    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.

  • DateTimeOffset

    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 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, and TimeZoneInfo

Discusses when to use the DateTime, DateTimeOffset, and TimeZoneInfo types when working with date and time data.

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 allow users to 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

Discusses the ways in which a DateTimeOffset object can be instantiated, and the ways in which a DateTime value can be converted to a DateTimeOffset value.

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 they 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

Discusses the issues involved in adding, subtracting, and comparing DateTime and DateTimeOffset values.

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

Describes how to convert between DateTime and DateTimeOffset values.

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.

Reference

TimeZoneInfo