本文整理匯總了VB.NET中System.DateTimeOffset.Now屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateTimeOffset.Now屬性的具體用法?VB.NET DateTimeOffset.Now怎麽用?VB.NET DateTimeOffset.Now使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.Now屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
Dim fmtStrings() As String = { "d", "D", "f", "F", "g", "G",
"M", "R", "s", "t", "T", "u",
"y" }
Dim value As DateTimeOffset = DateTimeOffset.Now
' Display date in default format.
Console.WriteLine(value)
Console.WriteLine()
' Display date using each of the specified formats.
For Each fmtString in fmtStrings
Console.WriteLine("{0} --> {1}",
fmtString, value.ToString(fmtString))
Next
End Sub
End Module
輸出:
11/19/2012 10:57:11 AM -08:00 d --> 11/19/2012 D --> Monday, November 19, 2012 f --> Monday, November 19, 2012 10:57 AM F --> Monday, November 19, 2012 10:57:11 AM g --> 11/19/2012 10:57 AM G --> 11/19/2012 10:57:11 AM M --> November 19 R --> Mon, 19 Nov 2012 18:57:11 GMT s --> 2012-11-19T10:57:11 t --> 10:57 AM T --> 10:57:11 AM u --> 2012-11-19 18:57:11Z y --> November, 2012
示例2:
Dim dto As DateTimeOffset
Dim ctr As Integer
Dim ms As Integer
Do
dto = DateTimeOffset.Now
If dto.Millisecond <> ms Then
ms = dto.Millisecond
Console.WriteLine("{0}:{1:d3} ms. {2}", _
dto.ToString("M/d/yyyy h:mm:ss"), _
ms, dto.ToString("zzz"))
ctr += 1
End If
Loop While ctr < 100