DateTimeOffset Constructor (DateTime)
Initializes a new instance of the DateTimeOffset structure using the specified DateTime value.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- dateTime
- Type: System::DateTime
A date and time.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The Coordinated Universal Time (UTC) date and time that results from applying the offset is earlier than MinValue. -or- The UTC date and time that results from applying the offset is later than MaxValue. |
This constructor's behavior depends on the value of the DateTime::Kind property of the dateTime parameter:
If the value of DateTime::Kind is DateTimeKind::Utc, the DateTime property of the new instance is set equal to dateTime, and the Offset property is set equal to Zero.
If the value of DateTime::Kind is DateTimeKind::Local or DateTimeKind::Unspecified, the DateTime property of the new instance is set equal to dateTime, and the Offset property is set equal to the offset of the local system's current time zone.
The following example illustrates how the value of the DateTime::Kind property of the dateTime parameter affects the date and time value that is returned by this constructor.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.