本文整理汇总了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