Converts a given DateTime object to DMTF format.
[Visual Basic] Public Shared Function ToDmtfDateTime( _ ByVal date As DateTime _ ) As String [C#] public static string ToDmtfDateTime( DateTime date ); [C++] public: static String* ToDmtfDateTime( DateTime date ); [JScript] public static function ToDmtfDateTime( date : DateTime ) : String;
- A DateTime object representing the datetime to be converted to DMTF datetime.
A string that represents the DMTF datetime for the given DateTime object.
Date and time in WMI is represented in DMTF datetime format. This format is explained in WMI SDK documentation. The DMTF datetime string represented will be with respect to the UTC offset of the current timezone. The lowest precision in DMTF is microseconds and in DateTime is Ticks, which is equivalent to 100 of nanoseconds. During conversion these Ticks are converted to microseconds and rounded off to the the nearest microsecond.
[C#] // Convert the current time in System.DateTime to DMTF format string dmtfDateTime = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now); [Visual Basic] ' Convert the current time in System.DateTime to DMTF format Dim dmtfDateTime as String = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now)
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code