本文整理匯總了VB.NET中System.DateTimeOffset.Subtract方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateTimeOffset.Subtract方法的具體用法?VB.NET DateTimeOffset.Subtract怎麽用?VB.NET DateTimeOffset.Subtract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.Subtract方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: DateTimeOffset
Dim firstDate As New DateTimeOffset(#10/25/2018 6:00PM#, _
New TimeSpan(-7, 0, 0))
Dim secondDate As New DateTimeOffset(#10/25/2018 6:00PM#, _
New TimeSpan(-5, 0, 0))
Dim thirdDate As New DateTimeOffset(#9/28/2018 9:00AM#, _
New TimeSpan(-7, 0, 0))
Dim difference As TimeSpan
difference = firstDate.Subtract(secondDate)
Console.WriteLine($"({firstDate}) - ({secondDate}): {difference.Days} days, {difference.Hours}:{difference.Minutes:d2}")
difference = firstDate.Subtract(thirdDate)
Console.WriteLine($"({firstDate}) - ({thirdDate}): {difference.Days} days, {difference.Hours}:{difference.Minutes:d2}")
輸出:
(10/25/2018 6:00:00 PM -07:00) - (10/25/2018 6:00:00 PM -05:00): 0 days, 2:00 (10/25/2018 6:00:00 PM -07:00) - (9/28/2018 9:00:00 AM -07:00): 27 days, 9:00
示例2: DateTimeOffset
Dim offsetDate As New DateTimeOffset(#12/3/2007 11:30AM#, _
New TimeSpan(-8, 0, 0))
Dim duration As New TimeSpan(7, 18, 0, 0)
Console.WriteLine(offsetDate.Subtract(duration)) ' Displays 11/25/2007 5:30:00 PM -08:00