GetTime Method  
 

Obtain the current system date and time.

Syntax

object.GetTime( [RemoteHost], [RemotePort], [Timeout], [Localize] )

Parameters

RemoteHost
A string which specifies the host name or IP address of the server. If this argument is not specified, it defaults to the value of the HostAddress property if it is defined. Otherwise, it defaults to the value of the HostName property.
RemotePort
A number which specifies the port to connect to on the server. If this argument is not specified, it defaults to the value of the RemotePort property. A value of zero indicates that the default port number for this service should be used to establish the connection.
Timeout
The number of seconds that the client will wait for a response before failing the operation. If this argument is not specified, the value of the Timeout property will be used as the default.
Localize
A boolean argument which specifies if the time should be localized to the timezone on the current system. If the value is True, then the time returned by the server will be adjusted so that it reflects the current time in the local timezone. If this argument is omitted or a value of false is passed to the method, the date and time are returned in Coordinated Universal Time (UTC).

Return Value

The time and date retrieved from the server will be returned as a string formatted according to the user's current locale. If the date could not be retrieved, an empty string will be returned. To determine the cause of the failure, check the value of the LastError property.

Remarks

The GetTime method causes the control to connect to the specified server and request the current date and time. In the United States, the National Institute of Standards and Technology (NIST) hosts a number of public servers which can be used to obtain the current time. The following table lists the current host names and addresses:

Server Name IP Address Location
time-a.nist.gov 129.6.15.28 Gaithersburg, Maryland
time-b.nist.gov 129.6.15.29 Gaithersburg, Maryland
time-nw.nist.gov 131.107.13.100 Redmond, Washington
time-a.timefreq.bldrdoc.gov 132.163.4.101 Boulder, Colorado
time-b.timefreq.bldrdoc.gov 132.163.4.102 Boulder, Colorado
time-c.timefreq.bldrdoc.gov 132.163.4.103 Boulder, Colorado

Time servers are also commonly maintained by Internet service providers and universities. If you are unable to obtain the time from a server, contact the system administrator to determine if they have the standard time service available on port 37.

See Also

LocalDate Property, LocalTime Property, SystemDate Property, SystemTime Property, SetTime Method