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.

public value class DateTime
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
struct time_point
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
public struct DateTimeOffset
var dateTime = {
universalTime : /* Your value */
}
Public Structure 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

See also