Export (0) Print
Expand All

ManagementDateTimeConverter.ToDmtfTimeInterval Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Converts a given TimeSpan object to DMTF time interval.

[Visual Basic]
Public Shared Function ToDmtfTimeInterval( _
   ByVal timespan As TimeSpan _
) As String
[C#]
public static string ToDmtfTimeInterval(
 TimeSpan timespan
);
[C++]
public: static String* ToDmtfTimeInterval(
 TimeSpan timespan
);
[JScript]
public static function ToDmtfTimeInterval(
   timespan : TimeSpan
) : String;

Parameters

timespan
A TimeSpan object representing the datetime to be converted to DMTF time interval.

Return Value

A string that represents the DMTF time interval for the given TimeSpan object.

Remarks

Time interval in WMI is represented in DMTF datetime format. This format is explained in WMI SDK documentation. The lowest precision in DMTF is microseconds and in TimeSpan 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.

Example

[C#] 
// Construct a Timespan object and convert it to DMTF format
System.TimeSpan ts = new System.TimeSpan(10,12,25,32,456);
String dmtfTimeInterval = ManagementDateTimeConverter.ToDmtfTimeInterval(ts);
   
[Visual Basic] 
// Construct a Timespan object and convert it to DMTF format
Dim ts as System.TimeSpan = new System.TimeSpan(10,12,25,32,456)
Dim dmtfTimeInterval as String = ManagementDateTimeConverter.ToDmtfTimeInterval(ts)
   

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

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: 

See Also

ManagementDateTimeConverter Class | ManagementDateTimeConverter Members | System.Management Namespace

Show:
© 2014 Microsoft