共用方式為


My.Computer.Clock.LocalTime Property 

Gets a Date object that contains the current local date and time on this computer.

' Usage
Dim value As Date = My.Computer.Clock.LocalTime
' Declaration
Public ReadOnly Property LocalTime As Date

Return Value

A Date object that contains the current local date and time.

Remarks

The My.Computer.Clock.LocalTime property has the same behavior as the System.DateTime.Now property.

Example

This example uses the My.Computer.Clock.LocalTime property to display the local time of the computer on which the code runs.

MsgBox("Current local time: " & My.Computer.Clock.LocalTime)

Requirements

Namespace: Microsoft.VisualBasic.Devices

Class: Clock

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

Permissions

No permissions are required.

See Also

Reference

My.Computer.Clock Object
My.Computer.Clock.GmtTime Property
System.DateTime.Now
Microsoft.VisualBasic.Devices.Clock.LocalTime