DateTime Struct

Definition

Represents an instant in time, typically expressed as a date and time of day.

JavaScript This type appears as the Date object.

.NET When programming with .NET, this type is hidden, and developers should use the System.DateTimeOffset structure.

C++/CX Similar to FILETIME but with important differences. See Remarks.

C++/WinRT This type is a specialization of std::chrono::time_point. See Remarks.

C#
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
public struct DateTimeOffset
Inheritance
DateTime
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced in v1.0)

Remarks

JavaScript and Microsoft .NET languages do not use this type directly. In JavaScript a DateTime is projected as a Date object, and in Microsoft .NET it is projected as a System.DateTimeOffset. Each language transparently handles the conversion to the granularity and date ranges for the respective language.

In Visual C++ component extensions (C++/CX), a DateTime.UniversalTime value has the same granularity as a FILETIME (100-nanosecond intervals). For positive values, a DateTime.UniversalTime value is identical to a FILETIME value although it can only represent dates up to about 29000 C.E. A negative value represents the number of intervals prior to January 1, 1601 and can represent dates back to about 27,400 B.C.E. For the Gregorian Calendar, you can use a DateTimeFormatter to create string representations of a DateTime for dates after midnight on Year 1 C.E.

To convert the UniversalTime to SYSTEMTIME, use ULARGE_INTEGER to convert the int64 value to FILETIME, then use FileTimeToSystemTime to get SYSTEMTIME.

In C++/WinRT, DateTime is similar to C++/CX in that it has the same granularity as a FILETIME. Unlike C++/CX, it is a specialization of std::chrono::time_point rather than a distinct struct. C++/WinRT provides helper functions to convert DateTime to and from FILETIME and to and from time_t. For more info about these functions, see winrt::clock struct.

Fields

UniversalTime

A 64-bit signed integer that represents a point in time as the number of 100-nanosecond intervals prior to or after midnight on January 1, 1601 (according to the Gregorian Calendar).

Note

In C++/WinRT, this field does not exist, because in that language projection DateTime is a specialization of std::chrono::time_point. If you need the raw integer value, use time_point::time_since_epoch to obtain a std::chrono::duration, and use its count method to obtain the raw count.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also