Export (0) Print
Expand All

DateTimeOffset.Now Property

Gets a DateTimeOffset object that is set to the current date and time on the current computer, with the offset set to the local time's offset from Coordinated Universal Time (UTC).

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Shared ReadOnly Property Now As DateTimeOffset

Property Value

Type: System.DateTimeOffset
A DateTimeOffset object whose date and time is the current local time and whose offset is the local time zone's offset from Coordinated Universal Time (UTC).

The precision of the current local time's millisecond component depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.

The following example uses the Now and Millisecond properties to determine the resolution of the system clock. It displays the time only when the value of its millisecond component has changed.


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


.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft