Редагувати

Поділитися через


DateAndTime.TimeString Property

Definition

Returns or sets a string value representing the current time of day according to your system.

public:
 static property System::String ^ TimeString { System::String ^ get(); void set(System::String ^ value); };
public static string TimeString { get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
public static string TimeString { get; set; }
[<set: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member TimeString : string with get, set
static member TimeString : string with get, set
Public Property TimeString As String

Property Value

Returns or sets a string value representing the current time of day according to your system.

Attributes

Exceptions

Invalid format used to set the value of TimeString.

Examples

This example uses the TimeString property to display the current system time.

MsgBox("The current time is " & TimeString)

Remarks

TimeString always returns the system time as "HH:mm:ss", which is a 24-hour format. This format is culture-invariant, which means it does not change even if you change the Regional Options in Control Panel.

To get or set the current system date as a String, use the DateString property.

To get the current system date or time in the format of your locale, or in a custom format, supply the Now property to the Format function, specifying either a predefined or user-defined date/time format. The following example demonstrates this.

MsgBox("The formatted time is " & Format(Now, "hh.mm.ss.fff tt"))  

To access the current system time as a Date, use the TimeOfDay property.

Important

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.

Applies to

See also