Converts a given TimeSpan to DMTF time interval.
Assembly: System.Management (in System.Management.dll)
'Declaration Public Shared Function ToDmtfTimeInterval ( _ timespan As TimeSpan _ ) As String
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; in TimeSpan, the lowest precision is Ticks, which is equivalent to 100 nanoseconds. During conversion, Ticks are converted to microseconds and rounded off to the nearest microsecond.
.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.
The following example converts a given TimeSpan to DMTF time interval.
Imports System Imports System.Management 'The sample below demonstrates the various conversions ' that can be done using ManagementDateTimeConverter class Class Sample_ManagementClass Public Overloads Shared Function Main(ByVal args() As String) _ As Integer Dim dmtfDate As String = "20020408141835.999999-420" Dim dmtfTimeInterval As String = "00000010122532:123456:000" 'Converting DMTF datetime and intervals to System.DateTime Dim dt As DateTime = _ ManagementDateTimeConverter.ToDateTime(dmtfDate) 'Converting System.DateTime to DMTF datetime dmtfDate = _ ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now) ' Converting DMTF timeinterval to System.TimeSpan Dim tsRet As System.TimeSpan = _ ManagementDateTimeConverter.ToTimeSpan(dmtfTimeInterval) 'Converting System.TimeSpan to DMTF time interval format Dim ts As System.TimeSpan = _ New System.TimeSpan(10, 12, 25, 32, 456) Dim dmtfTimeInt As String dmtfTimeInt = _ ManagementDateTimeConverter.ToDmtfTimeInterval(ts) Return 0 End Function End Class
- 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.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.