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. The network time value can represent a date and time up to the year 2036. It is important to note that the network time value is not the same as the UNIX time value that is used the standard C library time functions.

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-g.nist.gov 129.6.15.28 Gaithersburg, Maryland
time-b-g.nist.gov 129.6.15.29 Gaithersburg, Maryland
time-nw.nist.gov 131.107.13.100 Redmond, Washington
time-a-b.nist.gov 132.163.96.1 Boulder, Colorado
time-b-b.nist.gov 132.163.96.2 Boulder, Colorado
time-c-b.nist.gov 132.163.96.3 Boulder, Colorado

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

See Also

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