通过


DateAndTime.TimeString 属性

定义

返回或设置一个字符串值,该值代表系统当天的当前时间。

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

属性值

返回或设置一个字符串值,该值代表系统当天的当前时间。

属性

例外

用于设置值的格式 TimeString无效。

示例

此示例使用 TimeString 属性显示当前系统时间。

MsgBox("The current time is " & TimeString)

注解

TimeString 始终将系统时间返回为“HH:mm:ss”,这是一种 24 小时格式。 此格式是区域性固定格式,这意味着即使更改控制面板中的区域选项,也不会更改。

若要获取或设置当前系统日期, String请使用 DateString 该属性。

若要以区域设置的格式或自定义格式获取当前系统日期或时间,请向Format函数提供Now属性,并指定预定义或用户定义的日期/时间格式。 下面的示例演示这一操作。

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

若要以某种方式 Date访问当前系统时间,请使用该 TimeOfDay 属性。

重要

设置系统日期或时间需要非托管代码权限,这可能会影响其在部分信任情况下的执行。 有关详细信息,请参阅 SecurityPermission代码访问权限

适用于

另请参阅