DateAndTime.TimeOfDay Property

Returns or sets a Date value containing the current time of day according to your system.

Namespace: Microsoft.VisualBasic
Assembly: Microsoft.VisualBasic (in microsoft.visualbasic.dll)

public static DateTime TimeOfDay { get; set; }
/** @property */
public static DateTime get_TimeOfDay ()

/** @property */
public static void set_TimeOfDay (DateTime Value)

public static function get TimeOfDay () : DateTime

public static function set TimeOfDay (Value : DateTime)

Not applicable.

Property Value

Returns or sets a Date value containing the current time of day according to your system.

For more detailed information, see the Visual Basic topic TimeOfDay Property.

The Date data type includes date components. When returning the system time, TimeOfDay sets these all to 1, so the returned value represents the first day of the year 1. When setting the system time, TimeOfDay ignores the date components.

To access the current system time as a String, use the TimeString Property.

To get or set the current system date, use the Today Property.

Security noteSecurity Note:

Setting the system date or time requires unmanaged code permission, which might affect its execution in partial-trust situations. For more information, see SecurityPermission and Code Access Permissions.

This example uses the TimeOfDay property to return the current system time.

Dim currentTime As Date
currentTime = TimeOfDay

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0